cstruct

package
v1.79.0-mod Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package cstruct provides a helper for decoding binary data that is in the form of a padded C structure.

Index

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

func NewDecoder(b []byte) *Decoder

NewDecoder creates a Decoder from a byte slice.

func (*Decoder) Byte

func (d *Decoder) Byte() byte

Byte returns a single byte from the buffer.

func (*Decoder) Bytes

func (d *Decoder) Bytes(b []byte)

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.

func (*Decoder) Err

func (d *Decoder) Err() error

Err returns the first error that was encountered by this Decoder.

func (*Decoder) Int16

func (d *Decoder) Int16() int16

Int16 returns a int16 decoded from the buffer.

func (*Decoder) Int32

func (d *Decoder) Int32() int32

Int32 returns a int32 decoded from the buffer.

func (*Decoder) Int64

func (d *Decoder) Int64() int64

Int64 returns a int64 decoded from the buffer.

func (*Decoder) Offset

func (d *Decoder) Offset() int

Offset returns the current read offset for data in the buffer.

func (*Decoder) Uint16

func (d *Decoder) Uint16() uint16

Uint16 returns a uint16 decoded from the buffer.

func (*Decoder) Uint32

func (d *Decoder) Uint32() uint32

Uint32 returns a uint32 decoded from the buffer.

func (*Decoder) Uint64

func (d *Decoder) Uint64() uint64

Uint64 returns a uint64 decoded from the buffer.

func (*Decoder) Uintptr

func (d *Decoder) Uintptr() uintptr

Uintptr returns a uintptr decoded from the buffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL