Documentation
¶
Overview ¶
Package binary implements little-endian translation between 9P types and byte sequences.
Index ¶
- func Marshal(data []byte, v interface{}) ([]byte, int, error)
- func PutString(data []byte, v string) []byte
- func PutUint16(data []byte, v uint16) []byte
- func PutUint32(data []byte, v uint32) []byte
- func PutUint64(data []byte, v uint64) []byte
- func PutUint8(data []byte, v uint8) []byte
- func String(data []byte) string
- func Uint16(data []byte) uint16
- func Uint32(data []byte) uint32
- func Uint64(data []byte) uint64
- func Uint8(data []byte) uint8
- func Unmarshal(data []byte, v interface{}) ([]byte, error)
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Err() error
- func (b *Buffer) Len() int
- func (b *Buffer) PutString(v string)
- func (b *Buffer) PutUint16(v uint16)
- func (b *Buffer) PutUint32(v uint32)
- func (b *Buffer) PutUint64(v uint64)
- func (b *Buffer) PutUint8(v uint8)
- func (b *Buffer) Read(r io.Reader, size int) error
- func (b *Buffer) Reset()
- func (b *Buffer) String() string
- func (b *Buffer) Uint16() uint16
- func (b *Buffer) Uint32() uint32
- func (b *Buffer) Uint64() uint64
- func (b *Buffer) Uint8() uint8
- type Marshaler
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PutString ¶
PutString encodes a 16-bit count-delimited string to data. The returned slice may be a sub-slice of data if data was large enough to hold the entire encoded block. Otherwise, a newly allocated slice will be returned. It is valid to pass a nil data.
func PutUint16 ¶
PutUint16 encodes a unsigned 16-bit integer to data. The returned slice may be a sub-slice of data if data was large enough to hold the entire encoded block. Otherwise, a newly allocated slice will be returned. It is valid to pass a nil data.
func PutUint32 ¶
PutUint32 encodes a unsigned 32-bit integer to data. The returned slice may be a sub-slice of data if data was large enough to hold the entire encoded block. Otherwise, a newly allocated slice will be returned. It is valid to pass a nil data.
func PutUint64 ¶
PutUint64 encodes a unsigned 64-bit integer to data. The returned slice may be a sub-slice of data if data was large enough to hold the entire encoded block. Otherwise, a newly allocated slice will be returned. It is valid to pass a nil data.
func PutUint8 ¶
PutUint8 encodes a unsigned 8-bit integer to data. The returned slice may be a sub-slice of data if data was large enough to hold the entire encoded block. Otherwise, a newly allocated slice will be returned. It is valid to pass a nil data.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a variable-sized buffer of bytes used to encode and decode 9P primitives and messages.
func NewBuffer ¶
NewBuffer creates and initializes a new Buffer using data as its initial contents. The new Buffer takes ownership of data, and the caller should not use data after this call. NewBuffer is intended to prepare a Buffer to read existing data. It can also be used to size the internal buffer for writing. To do that, data should have the desired capacity but a length of zero.
func (*Buffer) Bytes ¶
Bytes returns a slice of length Len() holding the unread portion of the buffer. The slice is valid for use only until the next buffer modification.
func (*Buffer) Read ¶
Read reads exactly size bytes from r into buffer. The error is io.EOF only if no bytes were read. If an io.EOF happens after reading some but not all the bytes, Read returns io.ErrUnexpectedEOF.
func (*Buffer) Reset ¶
func (b *Buffer) Reset()
Reset resets the buffer to be empty, but it retains the underlying storage for use by future.
type Marshaler ¶
Marshaler is the interface implemented by an object that can marshal itself into a binary form. Marshal encodes the receiver into a binary form and returns the result.
type Unmarshaler ¶
Unmarshaler is the interface implemented by an object that can unmarshal a binary representation of itself. Unmarshal must be able to decode the form generated by Marshal. Unmarshal must copy the data if it wishes to retain the data after returning.