forked from quic-go/quic-go
use GoJay to marshal JSON
GoJay doesn't use reflection to marshal JSON. This allows dramatically faster encoding, as well as saving a large number of allocations.
This commit is contained in:
37
qlog/types.go
Normal file
37
qlog/types.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package qlog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
)
|
||||
|
||||
func toString(i int64) string {
|
||||
return strconv.FormatInt(i, 10)
|
||||
}
|
||||
|
||||
type versionNumber protocol.VersionNumber
|
||||
|
||||
func (v versionNumber) String() string {
|
||||
return fmt.Sprintf("%x", uint32(v))
|
||||
}
|
||||
|
||||
type streamType protocol.StreamType
|
||||
|
||||
func (s streamType) String() string {
|
||||
switch protocol.StreamType(s) {
|
||||
case protocol.StreamTypeUni:
|
||||
return "unidirectional"
|
||||
case protocol.StreamTypeBidi:
|
||||
return "bidirectional"
|
||||
default:
|
||||
panic("unknown stream type")
|
||||
}
|
||||
}
|
||||
|
||||
type connectionID protocol.ConnectionID
|
||||
|
||||
func (c connectionID) String() string {
|
||||
return fmt.Sprintf("%x", []byte(c))
|
||||
}
|
||||
Reference in New Issue
Block a user