Documentation ¶
Index ¶
- Constants
- func NewAggregate(errs []error) error
- func TryPack2DBytes(packer *Packer, valIntf interface{})
- func TryPackByte(packer *Packer, valIntf interface{})
- func TryPackBytes(packer *Packer, valIntf interface{})
- func TryPackClaimedIPPortList(packer *Packer, valIntf interface{})
- func TryPackHash(packer *Packer, valIntf interface{})
- func TryPackHashes(packer *Packer, valIntf interface{})
- func TryPackIP(packer *Packer, valIntf interface{})
- func TryPackInt(packer *Packer, valIntf interface{})
- func TryPackLong(packer *Packer, valIntf interface{})
- func TryPackStr(packer *Packer, valIntf interface{})
- func TryPackUint64Slice(p *Packer, valIntf interface{})
- func TryUnpack2DBytes(packer *Packer) interface{}
- func TryUnpackByte(packer *Packer) interface{}
- func TryUnpackBytes(packer *Packer) interface{}
- func TryUnpackClaimedIPPortList(packer *Packer) interface{}
- func TryUnpackHash(packer *Packer) interface{}
- func TryUnpackHashes(packer *Packer) interface{}
- func TryUnpackIP(packer *Packer) interface{}
- func TryUnpackInt(packer *Packer) interface{}
- func TryUnpackLong(packer *Packer) interface{}
- func TryUnpackStr(packer *Packer) interface{}
- func TryUnpackUint64Slice(p *Packer) interface{}
- type Closer
- type Errs
- type Packer
- func (p *Packer) CheckSpace(bytes int)
- func (p *Packer) Expand(bytes int)
- func (p *Packer) Pack2DByteSlice(byteSlices [][]byte)
- func (p *Packer) PackBool(b bool)
- func (p *Packer) PackByte(val byte)
- func (p *Packer) PackBytes(bytes []byte)
- func (p *Packer) PackClaimedIPPort(ipCert ips.ClaimedIPPort)
- func (p *Packer) PackFixedByteSlices(byteSlices [][]byte)
- func (p *Packer) PackFixedBytes(bytes []byte)
- func (p *Packer) PackIP(ip ips.IPPort)
- func (p *Packer) PackIPs(ips []ips.IPPort)
- func (p *Packer) PackInt(val uint32)
- func (p *Packer) PackLong(val uint64)
- func (p *Packer) PackShort(val uint16)
- func (p *Packer) PackStr(str string)
- func (p *Packer) PackX509Certificate(cert *x509.Certificate)
- func (p *Packer) Unpack2DByteSlice() [][]byte
- func (p *Packer) UnpackBool() bool
- func (p *Packer) UnpackByte() byte
- func (p *Packer) UnpackBytes() []byte
- func (p *Packer) UnpackClaimedIPPort() ips.ClaimedIPPort
- func (p *Packer) UnpackFixedByteSlices(size int) [][]byte
- func (p *Packer) UnpackFixedBytes(size int) []byte
- func (p *Packer) UnpackIP() ips.IPPort
- func (p *Packer) UnpackIPs() []ips.IPPort
- func (p *Packer) UnpackInt() uint32
- func (p *Packer) UnpackLong() uint64
- func (p *Packer) UnpackShort() uint16
- func (p *Packer) UnpackStr() string
- func (p *Packer) UnpackX509Certificate() *x509.Certificate
Constants ¶
const ( MaxStringLen = math.MaxUint16 // ByteLen is the number of bytes per byte... ByteLen = 1 // ShortLen is the number of bytes per short ShortLen = 2 // IntLen is the number of bytes per int IntLen = 4 // LongLen is the number of bytes per long LongLen = 8 // BoolLen is the number of bytes per bool BoolLen = 1 // IPLen is the number of bytes per IP IPLen = 16 + ShortLen )
Variables ¶
This section is empty.
Functions ¶
func NewAggregate ¶ added in v1.7.11
NewAggregate returns an aggregate error from a list of errors
func TryPack2DBytes ¶
func TryPack2DBytes(packer *Packer, valIntf interface{})
TryPack2DBytes attempts to pack the value as a 2D byte slice
func TryPackByte ¶
func TryPackByte(packer *Packer, valIntf interface{})
TryPackByte attempts to pack the value as a byte
func TryPackBytes ¶
func TryPackBytes(packer *Packer, valIntf interface{})
TryPackBytes attempts to pack the value as a list of bytes
func TryPackClaimedIPPortList ¶ added in v1.7.11
func TryPackClaimedIPPortList(packer *Packer, valIntf interface{})
func TryPackHash ¶
func TryPackHash(packer *Packer, valIntf interface{})
TryPackHash attempts to pack the value as a 32-byte sequence
func TryPackHashes ¶
func TryPackHashes(packer *Packer, valIntf interface{})
TryPackHashes attempts to pack the value as a list of 32-byte sequences
func TryPackIP ¶
func TryPackIP(packer *Packer, valIntf interface{})
TryPackIP attempts to pack the value as an ip port pair
func TryPackInt ¶
func TryPackInt(packer *Packer, valIntf interface{})
TryPackInt attempts to pack the value as an int
func TryPackLong ¶
func TryPackLong(packer *Packer, valIntf interface{})
TryPackLong attempts to pack the value as a long
func TryPackStr ¶
func TryPackStr(packer *Packer, valIntf interface{})
TryPackStr attempts to pack the value as a string
func TryPackUint64Slice ¶ added in v1.7.11
func TryPackUint64Slice(p *Packer, valIntf interface{})
func TryUnpack2DBytes ¶
func TryUnpack2DBytes(packer *Packer) interface{}
TryUnpack2DBytes attempts to unpack the value as a 2D byte slice
func TryUnpackByte ¶
func TryUnpackByte(packer *Packer) interface{}
TryUnpackByte attempts to unpack a value as a byte
func TryUnpackBytes ¶
func TryUnpackBytes(packer *Packer) interface{}
TryUnpackBytes attempts to unpack the value as a list of bytes
func TryUnpackClaimedIPPortList ¶ added in v1.7.11
func TryUnpackClaimedIPPortList(packer *Packer) interface{}
func TryUnpackHash ¶
func TryUnpackHash(packer *Packer) interface{}
TryUnpackHash attempts to unpack the value as a 32-byte sequence
func TryUnpackHashes ¶
func TryUnpackHashes(packer *Packer) interface{}
TryUnpackHashes attempts to unpack the value as a list of 32-byte sequences
func TryUnpackIP ¶
func TryUnpackIP(packer *Packer) interface{}
TryUnpackIP attempts to unpack the value as an ip port pair
func TryUnpackInt ¶
func TryUnpackInt(packer *Packer) interface{}
TryUnpackInt attempts to unpack a value as an int
func TryUnpackLong ¶
func TryUnpackLong(packer *Packer) interface{}
TryUnpackLong attempts to unpack a value as a long
func TryUnpackStr ¶
func TryUnpackStr(packer *Packer) interface{}
TryUnpackStr attempts to unpack the value as a string
func TryUnpackUint64Slice ¶ added in v1.7.11
func TryUnpackUint64Slice(p *Packer) interface{}
Types ¶
type Closer ¶
type Closer struct {
// contains filtered or unexported fields
}
Closer is a nice utility for closing a group of objects while reporting an error if one occurs.
type Packer ¶
type Packer struct { Errs // The largest allowed size of expanding the byte array MaxSize int // The current byte array Bytes []byte // The offset that is being written to in the byte array Offset int }
Packer packs and unpacks a byte array from/to standard values
func (*Packer) CheckSpace ¶
CheckSpace requires that there is at least bytes of write space left in the byte array. If this is not true, an error is added to the packer
func (*Packer) Expand ¶
Expand ensures that there is bytes bytes left of space in the byte slice. If this is not allowed due to the maximum size, an error is added to the packer In order to understand this code, its important to understand the difference between a slice's length and its capacity.
func (*Packer) Pack2DByteSlice ¶
Pack2DByteSlice append a 2D byte slice to the byte array
func (*Packer) PackClaimedIPPort ¶ added in v1.7.11
func (p *Packer) PackClaimedIPPort(ipCert ips.ClaimedIPPort)
func (*Packer) PackFixedByteSlices ¶
PackFixedByteSlices append a byte slice slice to the byte array
func (*Packer) PackFixedBytes ¶
PackFixedBytes append a byte slice, with no length descriptor to the byte array
func (*Packer) PackX509Certificate ¶
func (p *Packer) PackX509Certificate(cert *x509.Certificate)
func (*Packer) Unpack2DByteSlice ¶
Unpack2DByteSlice returns a 2D byte slice from the byte array.
func (*Packer) UnpackBool ¶
UnpackBool unpacks a bool from the byte array
func (*Packer) UnpackByte ¶
UnpackByte unpack a byte from the byte array
func (*Packer) UnpackBytes ¶
UnpackBytes unpack a byte slice from the byte array
func (*Packer) UnpackClaimedIPPort ¶ added in v1.7.11
func (p *Packer) UnpackClaimedIPPort() ips.ClaimedIPPort
func (*Packer) UnpackFixedByteSlices ¶
UnpackFixedByteSlices returns a byte slice slice from the byte array. Each byte slice has the specified size. The number of byte slices is read from the byte array.
func (*Packer) UnpackFixedBytes ¶
UnpackFixedBytes unpack a byte slice, with no length descriptor from the byte array
func (*Packer) UnpackLong ¶
UnpackLong unpack a long from the byte array
func (*Packer) UnpackShort ¶
UnpackShort unpack a short from the byte array
func (*Packer) UnpackX509Certificate ¶
func (p *Packer) UnpackX509Certificate() *x509.Certificate