package http3

import (
	

	
)

// Perspective determines if we're acting as a server or a client
type Perspective int

// the perspectives
const (
	PerspectiveServer Perspective = 1
	PerspectiveClient Perspective = 2
)

// Opposite returns the perspective of the peer
func ( Perspective) () Perspective {
	return 3 - 
}

func ( Perspective) () string {
	switch  {
	case PerspectiveServer:
		return "server"
	case PerspectiveClient:
		return "client"
	default:
		return "invalid perspective"
	}
}

// The version numbers, making grepping easier
const (
	VersionUnknown quic.Version = math.MaxUint32
	versionDraft29 quic.Version = 0xff00001d // draft-29 used to be a widely deployed version
	Version1       quic.Version = 0x1
	Version2       quic.Version = 0x6b3343cf
)

// StreamType encodes if this is a unidirectional or bidirectional stream
type StreamType uint8

const (
	// StreamTypeUni is a unidirectional stream
	StreamTypeUni StreamType = iota
	// StreamTypeBidi is a bidirectional stream
	StreamTypeBidi
)

// InvalidPacketNumber is a stream ID that is invalid.
// The first valid stream ID in QUIC is 0.
const InvalidStreamID quic.StreamID = -1

// StreamNum is the stream number
type StreamNum int64

const (
	// InvalidStreamNum is an invalid stream number.
	InvalidStreamNum = -1
	// MaxStreamCount is the maximum stream count value that can be sent in MAX_STREAMS frames
	// and as the stream count in the transport parameters
	MaxStreamCount StreamNum = 1 << 60
)

// StreamID calculates the stream ID.
func ( StreamNum) ( StreamType,  Perspective) quic.StreamID {
	if  == 0 {
		return InvalidStreamID
	}
	var  quic.StreamID
	switch  {
	case StreamTypeBidi:
		switch  {
		case PerspectiveClient:
			 = 0
		case PerspectiveServer:
			 = 1
		}
	case StreamTypeUni:
		switch  {
		case PerspectiveClient:
			 = 2
		case PerspectiveServer:
			 = 3
		}
	}
	return  + 4*quic.StreamID(-1)
}