Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec struct { }
Codec represents a CBOR codec for our network.
func (*Codec) Decode ¶
Decode will, given a []byte 'envelope', return a Golang interface 'v'. Return an error if unpacking the envelope fails. NOTE: 'v' is the network message payload in un-serialized form. NOTE: 'code' is the message type. NOTE: 'what' is the 'code' name for debugging / instrumentation. NOTE: 'envelope' contains 'code' & serialized / encoded 'v'. i.e. 1st byte is 'code' and remaining bytes are CBOR encoded 'v'. Expected error returns during normal operations:
- codec.ErrInvalidEncoding if message encoding is invalid.
- codec.ErrUnknownMsgCode if message code byte does not match any of the configured message codes.
- codec.ErrMsgUnmarshal if the codec fails to unmarshal the data to the message type denoted by the message code.
func (*Codec) Encode ¶
Encode will, given a Golang interface 'v', return a []byte 'envelope'. Return an error if packing the envelope fails. NOTE: 'v' is the network message payload in unserialized form. NOTE: 'code' is the message type. NOTE: 'what' is the 'code' name for debugging / instrumentation. NOTE: 'envelope' contains 'code' & serialized / encoded 'v'. i.e. 1st byte is 'code' and remaining bytes are CBOR encoded 'v'.
func (*Codec) NewDecoder ¶
NewDecoder creates a new CBOR decoder with the given underlying reader.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder implements a stream decoder for CBOR.
func (*Decoder) Decode ¶
Decode will decode the next CBOR value from the stream. Expected error returns during normal operations:
- codec.ErrInvalidEncoding if message encoding is invalid.
- codec.ErrUnknownMsgCode if message code byte does not match any of the configured message codes.
- codec.ErrMsgUnmarshal if the codec fails to unmarshal the data to the message type denoted by the message code.