Documentation ¶
Index ¶
- Constants
- func BytesStripRight(s []byte, pad byte) []byte
- func BytesTerminate(s []byte, term byte, includeTerm bool) []byte
- func BytesToStr(in []byte, decoder *encoding.Decoder) (string, error)
- func ProcessRotateLeft(data []byte, amount int) []byte
- func ProcessRotateRight(data []byte, amount int) []byte
- func ProcessXOR(data []byte, key []byte) []byte
- func ProcessZlib(in []byte) ([]byte, error)
- func StringReverse(s string) string
- type EndOfStreamError
- type Stream
- func (k *Stream) AlignToByte()
- func (k *Stream) EOF() (bool, error)
- func (k *Stream) Pos() (int64, error)
- func (k *Stream) ReadBitsArray(n uint) error
- func (k *Stream) ReadBitsInt(n uint8) (res uint64, err error)deprecated
- func (k *Stream) ReadBitsIntBe(n int) (res uint64, err error)
- func (k *Stream) ReadBitsIntLe(n int) (res uint64, err error)
- func (k *Stream) ReadBytes(n int) (b []byte, err error)
- func (k *Stream) ReadBytesFull() ([]byte, error)
- func (k *Stream) ReadBytesPadTerm(size int, term, pad byte, includeTerm bool) ([]byte, error)
- func (k *Stream) ReadBytesTerm(term byte, includeTerm, consumeTerm, eosError bool) ([]byte, error)
- func (k *Stream) ReadF4be() (v float32, err error)
- func (k *Stream) ReadF4le() (v float32, err error)
- func (k *Stream) ReadF8be() (v float64, err error)
- func (k *Stream) ReadF8le() (v float64, err error)
- func (k *Stream) ReadS1() (v int8, err error)
- func (k *Stream) ReadS2be() (v int16, err error)
- func (k *Stream) ReadS2le() (v int16, err error)
- func (k *Stream) ReadS4be() (v int32, err error)
- func (k *Stream) ReadS4le() (v int32, err error)
- func (k *Stream) ReadS8be() (v int64, err error)
- func (k *Stream) ReadS8le() (v int64, err error)
- func (k *Stream) ReadStrByteLimit(limit int, encoding string) (string, error)
- func (k *Stream) ReadStrEOS(encoding string) (string, error)
- func (k *Stream) ReadU1() (v uint8, err error)
- func (k *Stream) ReadU2be() (v uint16, err error)
- func (k *Stream) ReadU2le() (v uint16, err error)
- func (k *Stream) ReadU4be() (v uint32, err error)
- func (k *Stream) ReadU4le() (v uint32, err error)
- func (k *Stream) ReadU8be() (v uint64, err error)
- func (k *Stream) ReadU8le() (v uint64, err error)
- func (k *Stream) Size() (int64, error)
- type UndecidedEndiannessError
- type ValidationExprError
- type ValidationFailedError
- type ValidationGreaterThanError
- type ValidationLessThanError
- type ValidationNotAnyOfError
- type ValidationNotEqualError
- type Writer
- func (k *Writer) WriteBytes(b []byte) error
- func (k *Writer) WriteF4be(v float32) error
- func (k *Writer) WriteF4le(v float32) error
- func (k *Writer) WriteF8be(v float64) error
- func (k *Writer) WriteF8le(v float64) error
- func (k *Writer) WriteS1(v int8) error
- func (k *Writer) WriteS2be(v int16) error
- func (k *Writer) WriteS2le(v int16) error
- func (k *Writer) WriteS4be(v int32) error
- func (k *Writer) WriteS4le(v int32) error
- func (k *Writer) WriteS8be(v int64) error
- func (k *Writer) WriteS8le(v int64) error
- func (k *Writer) WriteU1(v uint8) error
- func (k *Writer) WriteU2be(v uint16) error
- func (k *Writer) WriteU2le(v uint16) error
- func (k *Writer) WriteU4be(v uint32) error
- func (k *Writer) WriteU4le(v uint32) error
- func (k *Writer) WriteU8be(v uint64) error
- func (k *Writer) WriteU8le(v uint64) error
Constants ¶
const APIVersion = 0x0001
APIVersion defines the currently used API version.
Variables ¶
This section is empty.
Functions ¶
func BytesStripRight ¶
BytesStripRight strips bytes of a given value off the end of the byte slice.
func BytesTerminate ¶
BytesTerminate terminates the given byte slice using the provided sentinel, optionally including the sentinel itself in the terminated byte slice.
func BytesToStr ¶
BytesToStr returns a string decoded by the given decoder.
func ProcessRotateLeft ¶
ProcessRotateLeft returns the single bytes in data rotated left by amount bits.
func ProcessRotateRight ¶
ProcessRotateRight returns the single bytes in data rotated right by amount bits.
func ProcessXOR ¶
ProcessXOR returns data xored with the key.
func ProcessZlib ¶
ProcessZlib decompresses the given bytes as specified in RFC 1950.
func StringReverse ¶
StringReverse returns the string s in reverse order.
Types ¶
type EndOfStreamError ¶
type EndOfStreamError struct{}
EndOfStreamError is returned when the stream unexpectedly ends.
func (EndOfStreamError) Error ¶
func (EndOfStreamError) Error() string
type Stream ¶
type Stream struct { io.ReadSeeker // contains filtered or unexported fields }
A Stream represents a sequence of bytes. It encapsulates reading from files and memory, stores pointer to its current position, and allows reading/writing of various primitives.
func NewStream ¶
func NewStream(r io.ReadSeeker) *Stream
NewStream creates and initializes a new Buffer based on r.
func (*Stream) AlignToByte ¶
func (k *Stream) AlignToByte()
AlignToByte discards the remaining bits and starts reading bits at the next byte.
func (*Stream) ReadBitsArray ¶
ReadBitsArray is not implemented yet.
func (*Stream) ReadBitsInt
deprecated
func (*Stream) ReadBitsIntBe ¶
ReadBitsIntBe reads n-bit integer in big-endian byte order and returns it as uint64.
func (*Stream) ReadBitsIntLe ¶
ReadBitsIntLe reads n-bit integer in little-endian byte order and returns it as uint64.
func (*Stream) ReadBytesFull ¶
ReadBytesFull reads all remaining bytes and returns those as a byte array.
func (*Stream) ReadBytesPadTerm ¶
ReadBytesPadTerm reads up to size bytes. pad bytes are discarded. It terminates reading, when the term byte occurs. The term byte is included in the returned byte array when includeTerm is set.
func (*Stream) ReadBytesTerm ¶
ReadBytesTerm reads bytes until the term byte is reached. If includeTerm is set the term bytes is included in the returned byte array. If consumeTerm is set the stream continues after the term byte. If eosError is set EOF errors result in an error.
func (*Stream) ReadF4le ¶
ReadF4le reads 4 bytes in little-endian order and returns those as float32.
func (*Stream) ReadF8le ¶
ReadF8le reads 8 bytes in little-endian order and returns those as float64.
func (*Stream) ReadStrByteLimit ¶
ReadStrByteLimit reads limit number of bytes and returns those as a string.
func (*Stream) ReadStrEOS ¶
ReadStrEOS reads the remaining bytes as a string.
func (*Stream) ReadU2le ¶
ReadU2le reads 2 bytes in little-endian order and returns those as uint16.
func (*Stream) ReadU4le ¶
ReadU4le reads 4 bytes in little-endian order and returns those as uint32.
type UndecidedEndiannessError ¶
type UndecidedEndiannessError struct{}
UndecidedEndiannessError occurs when a value has calculated or inherited endianness, and the endianness could not be determined.
func (UndecidedEndiannessError) Error ¶
func (UndecidedEndiannessError) Error() string
type ValidationExprError ¶
type ValidationExprError struct {
// contains filtered or unexported fields
}
ValidationExprError signals validation failure: we required "Actual" value to match the expression, but it turned out that it doesn't.
func NewValidationExprError ¶
func NewValidationExprError(actual interface{}, io *Stream, srcPath string) ValidationExprError
NewValidationExprError creates a new ValidationExprError instance.
func (ValidationExprError) Actual ¶
func (e ValidationExprError) Actual() interface{}
Actual is a getter of the actual value associated with the validation error.
func (ValidationExprError) Error ¶
func (e ValidationExprError) Error() string
type ValidationFailedError ¶
ValidationFailedError is an interface that all "Validation*Error"s implement.
type ValidationGreaterThanError ¶
type ValidationGreaterThanError struct {
// contains filtered or unexported fields
}
ValidationGreaterThanError signals validation failure: we required "Actual" value to be less than or equal to "Max", but it turned out that it's not.
func NewValidationGreaterThanError ¶
func NewValidationGreaterThanError(max interface{}, actual interface{}, io *Stream, srcPath string) ValidationGreaterThanError
NewValidationGreaterThanError creates a new ValidationGreaterThanError instance.
func (ValidationGreaterThanError) Actual ¶
func (e ValidationGreaterThanError) Actual() interface{}
Actual is a getter of the actual value associated with the validation error.
func (ValidationGreaterThanError) Error ¶
func (e ValidationGreaterThanError) Error() string
func (ValidationGreaterThanError) Max ¶
func (e ValidationGreaterThanError) Max() interface{}
Max is a getter of the maximum value associated with the validation error.
type ValidationLessThanError ¶
type ValidationLessThanError struct {
// contains filtered or unexported fields
}
ValidationLessThanError signals validation failure: we required "Actual" value to be greater than or equal to "Min", but it turned out that it's not.
func NewValidationLessThanError ¶
func NewValidationLessThanError(min interface{}, actual interface{}, io *Stream, srcPath string) ValidationLessThanError
NewValidationLessThanError creates a new ValidationLessThanError instance.
func (ValidationLessThanError) Actual ¶
func (e ValidationLessThanError) Actual() interface{}
Actual is a getter of the actual value associated with the validation error.
func (ValidationLessThanError) Error ¶
func (e ValidationLessThanError) Error() string
func (ValidationLessThanError) Min ¶
func (e ValidationLessThanError) Min() interface{}
Min is a getter of the minimum value associated with the validation error.
type ValidationNotAnyOfError ¶
type ValidationNotAnyOfError struct {
// contains filtered or unexported fields
}
ValidationNotAnyOfError signals validation failure: we required "Actual" value to be from the list, but it turned out that it's not.
func NewValidationNotAnyOfError ¶
func NewValidationNotAnyOfError(actual interface{}, io *Stream, srcPath string) ValidationNotAnyOfError
NewValidationNotAnyOfError creates a new ValidationNotAnyOfError instance.
func (ValidationNotAnyOfError) Actual ¶
func (e ValidationNotAnyOfError) Actual() interface{}
Actual is a getter of the actual value associated with the validation error.
func (ValidationNotAnyOfError) Error ¶
func (e ValidationNotAnyOfError) Error() string
type ValidationNotEqualError ¶
type ValidationNotEqualError struct {
// contains filtered or unexported fields
}
ValidationNotEqualError signals validation failure: we required "Actual" value to be equal to "Expected", but it turned out that it's not.
func NewValidationNotEqualError ¶
func NewValidationNotEqualError(expected interface{}, actual interface{}, io *Stream, srcPath string) ValidationNotEqualError
NewValidationNotEqualError creates a new ValidationNotEqualError instance.
func (ValidationNotEqualError) Actual ¶
func (e ValidationNotEqualError) Actual() interface{}
Actual is a getter of the actual value associated with the validation error.
func (ValidationNotEqualError) Error ¶
func (e ValidationNotEqualError) Error() string
func (ValidationNotEqualError) Expected ¶
func (e ValidationNotEqualError) Expected() interface{}
Expected is a getter of the expected value associated with the validation error.
type Writer ¶
A Writer encapsulates writing binary data to files and memory.
func (*Writer) WriteBytes ¶
WriteBytes writes the byte slice b to the underlying writer.
func (*Writer) WriteF4le ¶
WriteF4le writes a float32 in little-endian order to the underlying writer.
func (*Writer) WriteF8le ¶
WriteF8le writes a float64 in little-endian order to the underlying writer.
func (*Writer) WriteS2le ¶
WriteS2le writes an int16 in little-endian order to the underlying writer.
func (*Writer) WriteS4le ¶
WriteS4le writes an int32 in little-endian order to the underlying writer.
func (*Writer) WriteS8le ¶
WriteS8le writes an int64 in little-endian order to the underlying writer.
func (*Writer) WriteU2le ¶
WriteU2le writes a uint16 in little-endian order to the underlying writer.
func (*Writer) WriteU4le ¶
WriteU4le writes a uint32 in little-endian order to the underlying writer.