Documentation
¶
Index ¶
- Constants
- type BufferSink
- func (b *BufferSink) Bytes() []byte
- func (b *BufferSink) Cursor() int
- func (b *BufferSink) PutInt32LE(v int32) bool
- func (b *BufferSink) PutRange(src []byte) bool
- func (b *BufferSink) PutSleb128(value int32) bool
- func (b *BufferSink) PutUint8(v uint8) bool
- func (b *BufferSink) PutUint16LE(v uint16) bool
- func (b *BufferSink) PutUint32LE(v uint32) bool
- func (b *BufferSink) PutUint64LE(v uint64) bool
- func (b *BufferSink) PutUleb128(value uint32) bool
- func (b *BufferSink) Remaining() int
- type BufferSource
- func (b *BufferSource) Bytes() []byte
- func (b *BufferSource) CheckNextBytes(target []byte) bool
- func (b *BufferSource) ConsumeBytes(target []byte) bool
- func (b *BufferSource) Cursor() int
- func (b *BufferSource) GetInt32LE() (int32, bool)
- func (b *BufferSource) GetRegion(count int) ([]byte, bool)
- func (b *BufferSource) GetSleb128() (int32, bool)
- func (b *BufferSource) GetUint8() (uint8, bool)
- func (b *BufferSource) GetUint16LE() (uint16, bool)
- func (b *BufferSource) GetUint32LE() (uint32, bool)
- func (b *BufferSource) GetUint64LE() (uint64, bool)
- func (b *BufferSource) GetUleb128() (uint32, bool)
- func (b *BufferSource) RegionFrom(start int) []byte
- func (b *BufferSource) Remaining() int
- func (b *BufferSource) Skip(n int) bool
- func (b *BufferSource) SkipLeb128() bool
- type Sink
- type WriterSink
- func (s *WriterSink) Cursor() int64
- func (s *WriterSink) Err() error
- func (s *WriterSink) PutInt32LE(v int32) bool
- func (s *WriterSink) PutRange(data []byte) bool
- func (s *WriterSink) PutSleb128(value int32) bool
- func (s *WriterSink) PutUint8(v uint8) bool
- func (s *WriterSink) PutUint16LE(v uint16) bool
- func (s *WriterSink) PutUint32LE(v uint32) bool
- func (s *WriterSink) PutUint64LE(v uint64) bool
- func (s *WriterSink) PutUleb128(value uint32) bool
Constants ¶
const MaxLeb128Size = 5
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferSink ¶
type BufferSink struct {
// contains filtered or unexported fields
}
BufferSink acts like an output stream with convenience methods to serialize data into a contiguous byte slice. It tracks a write cursor.
func NewBufferSink ¶
func NewBufferSink(data []byte) *BufferSink
NewBufferSink creates a new BufferSink wrapping data.
func (*BufferSink) Bytes ¶
func (b *BufferSink) Bytes() []byte
Bytes returns the written portion of the buffer.
func (*BufferSink) Cursor ¶
func (b *BufferSink) Cursor() int
Cursor returns current write position.
func (*BufferSink) PutInt32LE ¶
func (b *BufferSink) PutInt32LE(v int32) bool
PutInt32LE writes a 4-byte little-endian signed int.
func (*BufferSink) PutRange ¶
func (b *BufferSink) PutRange(src []byte) bool
PutRange writes a slice of bytes starting at current cursor.
func (*BufferSink) PutSleb128 ¶
func (b *BufferSink) PutSleb128(value int32) bool
PutSleb128 encodes and writes a Signed LEB128 32-bit integer.
func (*BufferSink) PutUint8 ¶
func (b *BufferSink) PutUint8(v uint8) bool
PutUint8 writes a 1-byte unsigned int.
func (*BufferSink) PutUint16LE ¶
func (b *BufferSink) PutUint16LE(v uint16) bool
PutUint16LE writes a 2-byte little-endian unsigned int.
func (*BufferSink) PutUint32LE ¶
func (b *BufferSink) PutUint32LE(v uint32) bool
PutUint32LE writes a 4-byte little-endian unsigned int.
func (*BufferSink) PutUint64LE ¶
func (b *BufferSink) PutUint64LE(v uint64) bool
PutUint64LE writes an 8-byte little-endian unsigned int.
func (*BufferSink) PutUleb128 ¶
func (b *BufferSink) PutUleb128(value uint32) bool
PutUleb128 encodes and writes an Unsigned LEB128 32-bit integer.
func (*BufferSink) Remaining ¶
func (b *BufferSink) Remaining() int
Remaining returns the number of writeable bytes remaining.
type BufferSource ¶
type BufferSource struct {
// contains filtered or unexported fields
}
BufferSource acts like an input stream with convenience methods to parse data from a contiguous byte slice. It tracks a read cursor.
func NewBufferSource ¶
func NewBufferSource(data []byte) *BufferSource
NewBufferSource creates a new BufferSource wrapping data.
func NewBufferSourceFromOffset ¶
func NewBufferSourceFromOffset(data []byte, offset int) *BufferSource
NewBufferSourceFromOffset creates a BufferSource wrapping data, starting at offset.
func (*BufferSource) Bytes ¶
func (b *BufferSource) Bytes() []byte
Bytes returns the remaining byte slice from the cursor.
func (*BufferSource) CheckNextBytes ¶
func (b *BufferSource) CheckNextBytes(target []byte) bool
CheckNextBytes returns true if the next bytes match the provided target slice.
func (*BufferSource) ConsumeBytes ¶
func (b *BufferSource) ConsumeBytes(target []byte) bool
ConsumeBytes checks if the next bytes match target. If so, advances cursor and returns true.
func (*BufferSource) Cursor ¶
func (b *BufferSource) Cursor() int
func (*BufferSource) GetInt32LE ¶
func (b *BufferSource) GetInt32LE() (int32, bool)
GetInt32LE reads a 4-byte little-endian signed int and advances the cursor.
func (*BufferSource) GetRegion ¶
func (b *BufferSource) GetRegion(count int) ([]byte, bool)
GetRegion returns a sub-slice of count bytes and advances the cursor.
func (*BufferSource) GetSleb128 ¶
func (b *BufferSource) GetSleb128() (int32, bool)
GetSleb128 parses a Signed LEB128 32-bit integer and advances the cursor.
func (*BufferSource) GetUint8 ¶
func (b *BufferSource) GetUint8() (uint8, bool)
GetUint8 reads a 1-byte unsigned int and advances the cursor.
func (*BufferSource) GetUint16LE ¶
func (b *BufferSource) GetUint16LE() (uint16, bool)
GetUint16LE reads a 2-byte little-endian unsigned int and advances the cursor.
func (*BufferSource) GetUint32LE ¶
func (b *BufferSource) GetUint32LE() (uint32, bool)
GetUint32LE reads a 4-byte little-endian unsigned int and advances the cursor.
func (*BufferSource) GetUint64LE ¶
func (b *BufferSource) GetUint64LE() (uint64, bool)
GetUint64LE reads an 8-byte little-endian unsigned int and advances the cursor.
func (*BufferSource) GetUleb128 ¶
func (b *BufferSource) GetUleb128() (uint32, bool)
GetUleb128 parses an Unsigned LEB128 32-bit integer and advances the cursor.
func (*BufferSource) RegionFrom ¶
func (b *BufferSource) RegionFrom(start int) []byte
func (*BufferSource) Remaining ¶
func (b *BufferSource) Remaining() int
Remaining returns the number of bytes remaining from the cursor to the end.
func (*BufferSource) Skip ¶
func (b *BufferSource) Skip(n int) bool
Skip advances the cursor by n bytes. Returns true if sufficient bytes remain, or false (and moves cursor to end) if requested size exceeds remaining bytes.
func (*BufferSource) SkipLeb128 ¶
func (b *BufferSource) SkipLeb128() bool
SkipLeb128 skips over a LEB128 value without decoding its full integer.
type Sink ¶
type Sink interface {
PutUint8(uint8) bool
PutUint16LE(uint16) bool
PutUint32LE(uint32) bool
PutUint64LE(uint64) bool
PutInt32LE(int32) bool
PutRange([]byte) bool
PutUleb128(uint32) bool
PutSleb128(int32) bool
}
Sink is the sequential output contract used by patch serialization. Implementations may target a fixed buffer or an io.Writer.
type WriterSink ¶
type WriterSink struct {
// contains filtered or unexported fields
}
WriterSink serializes sequentially to an io.Writer and retains the first write error. A false return from any Put method is diagnosable through Err.
func NewWriterSink ¶
func NewWriterSink(w io.Writer) *WriterSink
func (*WriterSink) Cursor ¶
func (s *WriterSink) Cursor() int64
func (*WriterSink) Err ¶
func (s *WriterSink) Err() error
func (*WriterSink) PutInt32LE ¶
func (s *WriterSink) PutInt32LE(v int32) bool
func (*WriterSink) PutRange ¶
func (s *WriterSink) PutRange(data []byte) bool
func (*WriterSink) PutSleb128 ¶
func (s *WriterSink) PutSleb128(value int32) bool
func (*WriterSink) PutUint8 ¶
func (s *WriterSink) PutUint8(v uint8) bool
func (*WriterSink) PutUint16LE ¶
func (s *WriterSink) PutUint16LE(v uint16) bool
func (*WriterSink) PutUint32LE ¶
func (s *WriterSink) PutUint32LE(v uint32) bool
func (*WriterSink) PutUint64LE ¶
func (s *WriterSink) PutUint64LE(v uint64) bool
func (*WriterSink) PutUleb128 ¶
func (s *WriterSink) PutUleb128(value uint32) bool