Documentation ¶
Index ¶
- Variables
- type Reader
- type Writer
- func (w *Writer) Alloc(n uint) (uint, error)
- func (w *Writer) Bytes() []byte
- func (w *Writer) Reset()
- func (w *Writer) Write1At(offset uint, data uint8)
- func (w *Writer) Write2At(offset uint, data uint16)
- func (w *Writer) Write4At(offset uint, data uint32)
- func (w *Writer) Write8At(offset uint, data uint64)
- func (w *Writer) WriteAt(offset uint, data []byte)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrOutOfMemory happens when alloc is required while using NewFixedWriter. ErrOutOfMemory = errors.New("out-of-memory, FixedWriter can't reallocate") )
Functions ¶
This section is empty.
Types ¶
type Reader ¶
Reader holds the buffer to read data from.
func NewReader ¶
NewReader creates a Reader using the existent slice. The slice is supposed to have, and begin with, a Karmem encoded structure.
Reader is not current safe. You MUST not change the slice content while reading.
func (*Reader) IsValidOffset ¶
IsValidOffset check if the current offset and size is valid and accessible within the bounds.
type Writer ¶
type Writer struct { Memory []byte // contains filtered or unexported fields }
Writer holds the encoded, the finished encode can be retrieved by Writer.Bytes()
func NewFixedWriter ¶
NewFixedWriter creates a Writer from an existent memory segment/buffer. The memory can't be resized.
func (*Writer) Alloc ¶
Alloc allocates n bytes inside. It returns the offset and may return error if it's not possible to allocate.
func (*Writer) Bytes ¶
Bytes return the Karmem encoded bytes. It doesn't copy the content, and can't be re-used after Reset.
func (*Writer) Reset ¶
func (w *Writer) Reset()
Reset will reset the memory length, but keeps the memory capacity.