Documentation ¶
Overview ¶
Package cstruct provides a helper for decoding binary data that is in the form of a padded C structure.
Index ¶
- type Decoder
- func (d *Decoder) Byte() byte
- func (d *Decoder) Bytes(b []byte)
- func (d *Decoder) Err() error
- func (d *Decoder) Int16() int16
- func (d *Decoder) Int32() int32
- func (d *Decoder) Int64() int64
- func (d *Decoder) Offset() int
- func (d *Decoder) Uint16() uint16
- func (d *Decoder) Uint32() uint32
- func (d *Decoder) Uint64() uint64
- func (d *Decoder) Uintptr() uintptr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads and decodes padded fields from a slice of bytes. All fields are decoded with native endianness.
Methods of a Decoder do not return errors, but rather store any error within the Decoder. The first error can be obtained via the Err method; after the first error, methods will return the zero value for their type.
func NewDecoder ¶
NewDecoder creates a Decoder from a byte slice.
func (*Decoder) Bytes ¶
Byte returns a number of bytes from the buffer based on the size of the input slice. No padding is applied.
If an error is encountered or this Decoder has previously encountered an error, no changes are made to the provided buffer.