github.com/quic-go/quic-go@v0.44.0/internal/protocol/key_phase.go (about)

     1  package protocol
     2  
     3  // KeyPhase is the key phase
     4  type KeyPhase uint64
     5  
     6  // Bit determines the key phase bit
     7  func (p KeyPhase) Bit() KeyPhaseBit {
     8  	if p%2 == 0 {
     9  		return KeyPhaseZero
    10  	}
    11  	return KeyPhaseOne
    12  }
    13  
    14  // KeyPhaseBit is the key phase bit
    15  type KeyPhaseBit uint8
    16  
    17  const (
    18  	// KeyPhaseUndefined is an undefined key phase
    19  	KeyPhaseUndefined KeyPhaseBit = iota
    20  	// KeyPhaseZero is key phase 0
    21  	KeyPhaseZero
    22  	// KeyPhaseOne is key phase 1
    23  	KeyPhaseOne
    24  )
    25  
    26  func (p KeyPhaseBit) String() string {
    27  	//nolint:exhaustive
    28  	switch p {
    29  	case KeyPhaseZero:
    30  		return "0"
    31  	case KeyPhaseOne:
    32  		return "1"
    33  	default:
    34  		return "undefined"
    35  	}
    36  }