Documentation ¶
Index ¶
- Constants
- Variables
- func BinaryMarshalTo(b []byte, allowEmpty bool, marshalTo func([]byte) (int, error)) (int, error)
- func BinaryMarshalToSizedBuffer(b []byte, allowEmpty bool, marshalToSizedBuffer func([]byte) (int, error)) (int, error)
- func BinaryProtoSize(n int) int
- func BinaryUnmarshal(b []byte, unmarshal func([]byte) error) error
- func DecodeFixed32(r io.ByteReader) (v uint64, err error)
- func DecodeFixed32FromBytes(b []byte) (uint64, int)
- func DecodeFixed32FromBytesWithError(b []byte) (v uint64, n int, err error)
- func DecodeFixed64(r io.ByteReader) (uint64, error)
- func DecodeFixed64FromBytes(b []byte) (uint64, int)
- func DecodeFixed64FromBytesWithError(b []byte) (v uint64, n int, err error)
- func DecodePolymorphFromBytes(b []byte, onlyVarint bool) (id uint64, size int, err error)
- func DecodeVarint(r io.ByteReader) (uint64, error)
- func DecodeVarintFromBytes(bb []byte) (u uint64, n int)
- func DecodeVarintFromBytesWithError(bb []byte) (u uint64, n int, err error)
- func EncodeFixed32(w io.ByteWriter, u uint32) error
- func EncodeFixed32ToBytes(b []byte, u uint32) (int, error)
- func EncodeFixed64(w io.ByteWriter, u uint64) error
- func EncodeFixed64ToBytes(b []byte, u uint64) (int, error)
- func EncodeVarint(w io.ByteWriter, u uint64) error
- func EncodeVarintToBytes(b []byte, u uint64) (n int)
- func EncodeVarintToBytesWithError(b []byte, u uint64) (n int, err error)
- func GetPolymorphFieldSize(id uint64) int
- func IsValidFirstByteOfTag(firstByte byte) bool
- func SizeTag(fieldID int) int
- func SizeVarint32(x uint32) int
- func SizeVarint64(x uint64) int
- type ContentType
- type ContentTypeOptions
- type UintByteDecoderFunc
- type UintByteEncoderFunc
- type UintDecoderFunc
- type UintEncoderFunc
- type WireTag
- func MustReadAnyTag(r io.ByteReader) (wt WireTag, err error)
- func MustReadAnyTagValue(r io.ByteReader) (rt WireTag, u uint64, err error)
- func SafeWireTag(v uint64) (WireTag, error)
- func TryReadAnyTag(r io.ByteScanner) (wt WireTag, err error)
- func TryReadAnyTagValue(r io.ByteScanner) (rt WireTag, u uint64, err error)
- func (v WireTag) Check(expectedType WireType, expectedID int) error
- func (v WireTag) CheckActualTagValue(actual uint64) error
- func (v WireTag) CheckTag(expected WireTag) error
- func (v WireTag) CheckType(t WireType) error
- func (v WireTag) Ensure(expectedType WireType, expectedID int)
- func (v WireTag) EnsureFixedFieldSize(sz int) WireTag
- func (v WireTag) EnsureTag(expected WireTag)
- func (v WireTag) EnsureType(expectedType WireType)
- func (v WireTag) FieldID() int
- func (v WireTag) FieldSize(u uint64) uint64
- func (v WireTag) FixedFieldSize() int
- func (v WireTag) IsValid() bool
- func (v WireTag) IsValidFirstByte(firstByte byte) bool
- func (v WireTag) IsZero() bool
- func (v WireTag) MaxFieldSize() (isFixed bool, max int)
- func (v WireTag) MustRead(r io.ByteReader) uint64
- func (v WireTag) MustWrite(w io.ByteWriter, u uint64)
- func (v WireTag) ReadTag(r io.ByteReader) error
- func (v WireTag) ReadTagValue(r io.ByteReader) (uint64, error)
- func (v WireTag) ReadValue(r io.ByteReader) (uint64, error)
- func (v WireTag) ReadValueFromBytes(b []byte) (uint64, int, error)
- func (v WireTag) String() string
- func (v WireTag) TagSize() int
- func (v WireTag) TryReadTag(r io.ByteScanner) (WireTag, error)
- func (v WireTag) Type() WireType
- func (v WireTag) WriteTagValue(w io.ByteWriter, u uint64) error
- func (v WireTag) WriteTagValueToBytes(b []byte, u uint64) (int, error)
- func (v WireTag) WriteValue(w io.ByteWriter, u uint64) error
- func (v WireTag) WriteValueToBytes(b []byte, u uint64) (int, error)
- type WireType
- func (v WireType) DataSize() (minSize, maxSize int)
- func (v WireType) FieldSize(tagSize int, u uint64) uint64
- func (v WireType) IsValid() bool
- func (v WireType) IsValidFirstByte(firstByte byte) bool
- func (v WireType) ReadTag(r io.ByteReader) (WireTag, error)
- func (v WireType) ReadTagValue(r io.ByteReader) (WireTag, uint64, error)
- func (v WireType) ReadValue(r io.ByteReader) (uint64, error)
- func (v WireType) ReadValueFromBytes(b []byte) (uint64, int, error)
- func (v WireType) String() string
- func (v WireType) Tag(fieldID int) WireTag
- func (v WireType) TryReadTag(r io.ByteScanner) (WireTag, error)
- func (v WireType) UintByteDecoder() (UintByteDecoderFunc, error)
- func (v WireType) UintByteEncoder() (UintByteEncoderFunc, error)
- func (v WireType) UintDecoder() (UintDecoderFunc, error)
- func (v WireType) UintEncoder() (UintEncoderFunc, error)
- func (v WireType) WriteValue(w io.ByteWriter, u uint64) error
- func (v WireType) WriteValueToBytes(b []byte, u uint64) (int, error)
Constants ¶
View Source
const ( ObjectMarker = illegalUtf8FirstByte | byte(WireVarint) // 16:varint // _Marker = illegalUtf8FirstByte | byte(WireFixed64) // 16:fixed64 // _Marker = illegalUtf8FirstByte | byte(WireBytes) // 16:bytes // DO_NOT_USE = illegalUtf8FirstByte | byte(WireStartGroup) // 16:groupStart BinaryMarker = illegalUtf8FirstByte | byte(WireEndGroup) // 16:groupEnd )
View Source
const ( WireTypeBits = 3 MaxVarintSize = binary.MaxVarintLen64 MinVarintSize = 1 MaxFieldID = math.MaxUint32 >> WireTypeBits )
View Source
const ExplicitEmptyBinaryProtoSize = 1
View Source
const (
GeneralBinaryMarker = BinaryMarker | iota<<WireTypeBits
)
As a valid pbuf payload cant start with groupEnd tag, so we can use it as an indicator of a non-parsable payload. Number of BinaryMarkers is limited by valid UTF-8 codes, starting at 0xC0
View Source
const MaxPolymorphFieldSize = 2 + MaxVarintSize
View Source
const MaxSafeForPolymorphFieldID = (legalUtf8 >> WireTypeBits) - 1
View Source
const MinPolymorphFieldSize = 2 + MinVarintSize
View Source
const PolymorphFieldID = illegalUtf8FirstByte >> WireTypeBits // = 16
Variables ¶
View Source
var ErrUnexpectedHeader = errors.New("unexpected header")
Functions ¶
func BinaryMarshalTo ¶
func BinaryProtoSize ¶
func DecodeFixed32 ¶
func DecodeFixed32(r io.ByteReader) (v uint64, err error)
func DecodeFixed32FromBytes ¶
func DecodeFixed64 ¶
func DecodeFixed64(r io.ByteReader) (uint64, error)
func DecodeFixed64FromBytes ¶
func DecodeVarint ¶
func DecodeVarint(r io.ByteReader) (uint64, error)
func DecodeVarintFromBytes ¶
func EncodeFixed32 ¶
func EncodeFixed32(w io.ByteWriter, u uint32) error
func EncodeFixed64 ¶
func EncodeFixed64(w io.ByteWriter, u uint64) error
func EncodeVarint ¶
func EncodeVarint(w io.ByteWriter, u uint64) error
func EncodeVarintToBytes ¶
func GetPolymorphFieldSize ¶
func IsValidFirstByteOfTag ¶
func SizeVarint32 ¶
func SizeVarint64 ¶
SizeVarint returns the varint encoding size of an integer.
Types ¶
type ContentType ¶
type ContentType uint8
Content type detection of a notation-friendly payload.
const ( /* Content is unclear */ ContentUndefined ContentType = iota /* Content is text */ ContentText /* Content is binary */ ContentBinary /* Content is protobuf message */ ContentMessage /* Content is protobuf that follows the notation and has polymorph marker */ ContentPolymorph )
func PeekContentTypeAndPolymorphID ¶
func PeekContentTypeAndPolymorphID(r io.ByteScanner) (ContentType, uint64, error)
func PeekContentTypeAndPolymorphIDFromBytes ¶
func PeekContentTypeAndPolymorphIDFromBytes(b []byte) (ContentType, uint64, error)
type ContentTypeOptions ¶
type ContentTypeOptions uint8
const ( // ContentOptionText indicates that the content can be text ContentOptionText ContentTypeOptions = 1 << iota // ContentOptionMessage indicates that the content can be a protobuf message ContentOptionMessage // ContentOptionNotation indicates the content has either Polymorph or Binary markers ContentOptionNotation )
func PeekPossibleContentTypes ¶
func PeekPossibleContentTypes(r io.ByteScanner) (ContentTypeOptions, error)
func PossibleContentTypes ¶
func PossibleContentTypes(firstByte byte) (ct ContentTypeOptions)
Provides content type detection of a notation-friendly payload.
type UintDecoderFunc ¶
type UintDecoderFunc func(io.ByteReader) (uint64, error)
type UintEncoderFunc ¶
type UintEncoderFunc func(io.ByteWriter, uint64) error
type WireTag ¶
type WireTag uint32
func MustReadAnyTag ¶
func MustReadAnyTag(r io.ByteReader) (wt WireTag, err error)
func MustReadAnyTagValue ¶
func MustReadAnyTagValue(r io.ByteReader) (rt WireTag, u uint64, err error)
func SafeWireTag ¶
func TryReadAnyTag ¶
func TryReadAnyTag(r io.ByteScanner) (wt WireTag, err error)
func TryReadAnyTagValue ¶
func TryReadAnyTagValue(r io.ByteScanner) (rt WireTag, u uint64, err error)
func (WireTag) CheckActualTagValue ¶
func (WireTag) EnsureFixedFieldSize ¶
func (WireTag) EnsureType ¶
func (WireTag) FixedFieldSize ¶
func (WireTag) IsValidFirstByte ¶
func (WireTag) MaxFieldSize ¶
func (WireTag) ReadTagValue ¶
func (v WireTag) ReadTagValue(r io.ByteReader) (uint64, error)
func (WireTag) ReadValueFromBytes ¶
func (WireTag) TryReadTag ¶
func (v WireTag) TryReadTag(r io.ByteScanner) (WireTag, error)
func (WireTag) WriteTagValue ¶
func (v WireTag) WriteTagValue(w io.ByteWriter, u uint64) error
func (WireTag) WriteTagValueToBytes ¶
func (WireTag) WriteValue ¶
func (v WireTag) WriteValue(w io.ByteWriter, u uint64) error
type WireType ¶
type WireType uint8
func (WireType) IsValidFirstByte ¶
func (WireType) ReadTagValue ¶
func (WireType) ReadValueFromBytes ¶
func (WireType) TryReadTag ¶
func (v WireType) TryReadTag(r io.ByteScanner) (WireTag, error)
func (WireType) UintByteDecoder ¶
func (v WireType) UintByteDecoder() (UintByteDecoderFunc, error)
func (WireType) UintByteEncoder ¶
func (v WireType) UintByteEncoder() (UintByteEncoderFunc, error)
func (WireType) UintDecoder ¶
func (v WireType) UintDecoder() (UintDecoderFunc, error)
func (WireType) UintEncoder ¶
func (v WireType) UintEncoder() (UintEncoderFunc, error)
func (WireType) WriteValue ¶
func (v WireType) WriteValue(w io.ByteWriter, u uint64) error
Click to show internal directories.
Click to hide internal directories.