File: key_phase.go

package info (click to toggle)
golang-github-lucas-clemente-quic-go 0.54.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,312 kB
  • sloc: sh: 54; makefile: 7
file content (36 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package protocol

// KeyPhase is the key phase
type KeyPhase uint64

// Bit determines the key phase bit
func (p KeyPhase) Bit() KeyPhaseBit {
	if p%2 == 0 {
		return KeyPhaseZero
	}
	return KeyPhaseOne
}

// KeyPhaseBit is the key phase bit
type KeyPhaseBit uint8

const (
	// KeyPhaseUndefined is an undefined key phase
	KeyPhaseUndefined KeyPhaseBit = iota
	// KeyPhaseZero is key phase 0
	KeyPhaseZero
	// KeyPhaseOne is key phase 1
	KeyPhaseOne
)

func (p KeyPhaseBit) String() string {
	//nolint:exhaustive
	switch p {
	case KeyPhaseZero:
		return "0"
	case KeyPhaseOne:
		return "1"
	default:
		return "undefined"
	}
}