Documentation
¶
Index ¶
- func Decode1Byte(byteOrder binary.ByteOrder, source []byte) int
- func Decode2Byte(byteOrder binary.ByteOrder, source []byte) int
- func Decode4Byte(byteOrder binary.ByteOrder, source []byte) int
- func Decode8Byte(byteOrder binary.ByteOrder, source []byte) int
- func MakeSimpleDataFrame(data []byte) []byte
- type Codec
- type CodecChain
- type Config
- type FrameBuffer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeSimpleDataFrame ¶
MakeSimpleDataFrame returns a new buffer with the length prepended as a 4 byte big endian unsigned integer. The length includes its own size in the calculation
Types ¶
type Codec ¶
type Codec interface {
// Encodes a byte array and returns the encoded byte array. If no encoded data is available, `nil` will be returned.
// If an empty/null payload is passed to encode, the chain of codecs will be flushed for any remaining data which has not
// yet been encoded.
Encode(data []byte) ([]byte, error)
// Decodes a byte array and returns the decoded byte array. If a decoder buffers and/or insufficient data is
// available, `nil` will be returned.
Decode([]byte) ([]byte, error)
}
type CodecChain ¶
type CodecChain struct {
// contains filtered or unexported fields
}
CodecChain returns a Codec interface representing a chain of codecs
func NewCodecChain ¶
func NewCodecChain(codecs ...Codec) *CodecChain
type Config ¶
type Config struct {
LengthOffset int
LengthFieldInBytes int
LengthFieldByteOrder binary.ByteOrder
SizeBiasInBytes int // The size bias is the number of bytes which should be added (including negative numbers) to the length in order to determine the entire frame size
// contains filtered or unexported fields
}
type FrameBuffer ¶
type FrameBuffer struct {
// contains filtered or unexported fields
}
FrameBuffer is a buffer intended to parse and emit arbitrary framed data, where all that needs to be known is the length offset in the frame payload, the size of the length field, and the endianness of the data.
func NewFrameBuffer ¶
func NewFrameBuffer(config Config) *FrameBuffer
func (*FrameBuffer) Read ¶
func (fb *FrameBuffer) Read() []byte
func (*FrameBuffer) Write ¶
func (fb *FrameBuffer) Write(data []byte)
Click to show internal directories.
Click to hide internal directories.