Documentation
¶
Overview ¶
Package byteops provides helper functions to (un-) marshal objects from or into a buffer
Index ¶
- func Fp32SliceFromBytes(vector []byte) []float32
- func Fp32SliceOfSlicesFromBytes(bytes []byte) ([][]float32, error)
- func Fp32SliceOfSlicesToBytes(slices [][]float32) []byte
- func Fp32SliceToBytes(slice []float32) []byte
- func Fp64SliceFromBytes(vector []byte) []float64
- func Fp64SliceToBytes(floats []float64) []byte
- func IntsFromByteVector(vector []byte) []int64
- func IntsToByteVector(ints []float64) []byte
- func WithPosition(pos uint64) func(*ReadWriter)
- type ReadWriter
- func (bo *ReadWriter) CopyBytesFromBuffer(length uint64, out []byte) ([]byte, error)
- func (bo *ReadWriter) CopyBytesToBuffer(copyBytes []byte) error
- func (bo *ReadWriter) CopyBytesToBufferWithUint32LengthIndicator(copyBytes []byte) error
- func (bo *ReadWriter) CopyBytesToBufferWithUint64LengthIndicator(copyBytes []byte) error
- func (bo *ReadWriter) DiscardBytesFromBufferWithUint32LengthIndicator() uint32
- func (bo *ReadWriter) DiscardBytesFromBufferWithUint64LengthIndicator() uint64
- func (bo *ReadWriter) MoveBufferPositionForward(length uint64)
- func (bo *ReadWriter) MoveBufferToAbsolutePosition(pos uint64)
- func (bo *ReadWriter) ReadBytesFromBuffer(length uint64) []byte
- func (bo *ReadWriter) ReadBytesFromBufferWithUint32LengthIndicator() []byte
- func (bo *ReadWriter) ReadBytesFromBufferWithUint64LengthIndicator() []byte
- func (bo *ReadWriter) ReadUint16() uint16
- func (bo *ReadWriter) ReadUint32() uint32
- func (bo *ReadWriter) ReadUint64() uint64
- func (bo *ReadWriter) ReadUint8() uint8
- func (bo *ReadWriter) ResetBuffer(buf []byte)
- func (bo *ReadWriter) WriteByte(b byte)
- func (bo *ReadWriter) WriteUint16(value uint16)
- func (bo *ReadWriter) WriteUint32(value uint32)
- func (bo *ReadWriter) WriteUint64(value uint64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fp32SliceFromBytes ¶ added in v1.29.0
func Fp32SliceOfSlicesFromBytes ¶ added in v1.29.0
Fp32SliceOfSlicesToBytes converts a slice of slices of float64 to a byte slice
Within the byte slice, it determines the dimensions of the inner slices using the first two bytes inferred as uint16 type The rest of the bytes are the float32 values.
If the byte slice is empty, it returns an empty slice of slices. If the dimension is found to be 0 then an error is returned as this is invalid.
func Fp32SliceOfSlicesToBytes ¶ added in v1.29.0
Fp32SliceOfSlicesToBytes converts a slice of slices of float64 to a byte slice
Within the byte slice, it encodes the first two bytes as the number of dimensions with uint16 type The rest of the bytes are the float32 values.
If the outer slice is empty, it returns an empty byte slice. If the first slice is empty, it returns an empty byte slice.
func Fp32SliceToBytes ¶ added in v1.29.0
func Fp64SliceFromBytes ¶ added in v1.29.0
func Fp64SliceToBytes ¶ added in v1.29.0
func IntsFromByteVector ¶ added in v1.25.0
func IntsToByteVector ¶ added in v1.25.0
func WithPosition ¶
func WithPosition(pos uint64) func(*ReadWriter)
Types ¶
type ReadWriter ¶
func NewReadWriter ¶
func NewReadWriter(buf []byte, opts ...func(writer *ReadWriter)) ReadWriter
func (*ReadWriter) CopyBytesFromBuffer ¶
func (bo *ReadWriter) CopyBytesFromBuffer(length uint64, out []byte) ([]byte, error)
func (*ReadWriter) CopyBytesToBuffer ¶
func (bo *ReadWriter) CopyBytesToBuffer(copyBytes []byte) error
func (*ReadWriter) CopyBytesToBufferWithUint32LengthIndicator ¶
func (bo *ReadWriter) CopyBytesToBufferWithUint32LengthIndicator(copyBytes []byte) error
Writes a uint32 length indicator about the buffer that's about to follow, then writes the buffer itself
func (*ReadWriter) CopyBytesToBufferWithUint64LengthIndicator ¶
func (bo *ReadWriter) CopyBytesToBufferWithUint64LengthIndicator(copyBytes []byte) error
Writes a uint64 length indicator about the buffer that's about to follow, then writes the buffer itself
func (*ReadWriter) DiscardBytesFromBufferWithUint32LengthIndicator ¶
func (bo *ReadWriter) DiscardBytesFromBufferWithUint32LengthIndicator() uint32
func (*ReadWriter) DiscardBytesFromBufferWithUint64LengthIndicator ¶
func (bo *ReadWriter) DiscardBytesFromBufferWithUint64LengthIndicator() uint64
func (*ReadWriter) MoveBufferPositionForward ¶
func (bo *ReadWriter) MoveBufferPositionForward(length uint64)
func (*ReadWriter) MoveBufferToAbsolutePosition ¶
func (bo *ReadWriter) MoveBufferToAbsolutePosition(pos uint64)
func (*ReadWriter) ReadBytesFromBuffer ¶
func (bo *ReadWriter) ReadBytesFromBuffer(length uint64) []byte
func (*ReadWriter) ReadBytesFromBufferWithUint32LengthIndicator ¶
func (bo *ReadWriter) ReadBytesFromBufferWithUint32LengthIndicator() []byte
func (*ReadWriter) ReadBytesFromBufferWithUint64LengthIndicator ¶
func (bo *ReadWriter) ReadBytesFromBufferWithUint64LengthIndicator() []byte
func (*ReadWriter) ReadUint16 ¶
func (bo *ReadWriter) ReadUint16() uint16
func (*ReadWriter) ReadUint32 ¶
func (bo *ReadWriter) ReadUint32() uint32
func (*ReadWriter) ReadUint64 ¶
func (bo *ReadWriter) ReadUint64() uint64
func (*ReadWriter) ReadUint8 ¶
func (bo *ReadWriter) ReadUint8() uint8
func (*ReadWriter) ResetBuffer ¶ added in v1.23.0
func (bo *ReadWriter) ResetBuffer(buf []byte)
func (*ReadWriter) WriteByte ¶
func (bo *ReadWriter) WriteByte(b byte)
func (*ReadWriter) WriteUint16 ¶
func (bo *ReadWriter) WriteUint16(value uint16)
func (*ReadWriter) WriteUint32 ¶
func (bo *ReadWriter) WriteUint32(value uint32)
func (*ReadWriter) WriteUint64 ¶
func (bo *ReadWriter) WriteUint64(value uint64)