Documentation
¶
Overview ¶
Package cobs implements Consistent Overhead Byte Stuffing (COBS) encoding and decoding algorithms for efficient, reliable and unambiguous packet framing.
Index ¶
Constants ¶
const (
Delimiter = byte(0x00) // packet framing delimiter.
)
Variables ¶
var EOD = errors.New("EOD")
EOD is the error returned when decoding and a delimiter was written. Functions return EOD to signal a graceful end of a frame.
var ErrIncompleteFrame = errors.New("frame incomplete")
ErrIncompleteData means a decoder was closed with an incomplete frame.
var ErrUnexpectedEOD = errors.New("unexpected EOD")
ErrUnexpectedEOD means that a delimiter was encountered in a malformed frame.
Functions ¶
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder implements the io.Writer and io.ByteWriter interfaces. Data written will we be decoded and forwarded byte per byte.
func NewDecoder ¶
NewDecoder returns a Decoder that writes decoded data to w.
func (*Decoder) NeedsMoreData ¶ added in v1.1.0
NeedsMoreData returns true if the decoder needs more data for a full frame.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder implements the io.Writer and io.ByteWriter interfaces. Data written will we be encoded into groups and forwarded.
func NewEncoder ¶
NewEncoder returns an Encoder that writes encoded data to w.
func (*Encoder) Close ¶
Close has to be called after writing a full frame and will write the last group.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
decode
Decode reads from standard input, and writes the decoded data to standard output.
|
Decode reads from standard input, and writes the decoded data to standard output. |
encode
Encode reads from standard input, and writes the encoded data to standard output.
|
Encode reads from standard input, and writes the encoded data to standard output. |