Documentation ¶
Index ¶
- type BinaryDecoder
- func (d *BinaryDecoder) ReadBoolean() (bool, error)
- func (d *BinaryDecoder) ReadBuffer() ([]byte, error)
- func (d *BinaryDecoder) ReadByte() (byte, error)
- func (d *BinaryDecoder) ReadDouble() (float64, error)
- func (d *BinaryDecoder) ReadEnd() error
- func (d *BinaryDecoder) ReadFloat() (float32, error)
- func (d *BinaryDecoder) ReadInt() (int32, error)
- func (d *BinaryDecoder) ReadLong() (int64, error)
- func (d *BinaryDecoder) ReadMapEnd() error
- func (d *BinaryDecoder) ReadMapStart() (int, error)
- func (d *BinaryDecoder) ReadRecord(r RecordReader) error
- func (d *BinaryDecoder) ReadStart() error
- func (d *BinaryDecoder) ReadString() (string, error)
- func (d *BinaryDecoder) ReadVectorEnd() error
- func (d *BinaryDecoder) ReadVectorStart() (int, error)
- type BinaryEncoder
- func (s *BinaryEncoder) Encode(r RecordWriter) error
- func (s *BinaryEncoder) WriteBoolean(b bool) error
- func (s *BinaryEncoder) WriteBuffer(v []byte) error
- func (s *BinaryEncoder) WriteByte(b byte) error
- func (s *BinaryEncoder) WriteDouble(i float64) error
- func (s *BinaryEncoder) WriteEnd() error
- func (s *BinaryEncoder) WriteFloat(i float32) error
- func (s *BinaryEncoder) WriteInt(i int32) error
- func (s *BinaryEncoder) WriteLong(i int64) error
- func (s *BinaryEncoder) WriteMapEnd() error
- func (s *BinaryEncoder) WriteMapStart(l int) error
- func (s *BinaryEncoder) WriteRecord(r RecordWriter) error
- func (s *BinaryEncoder) WriteStart() error
- func (s *BinaryEncoder) WriteString(v string) error
- func (s *BinaryEncoder) WriteVectorEnd() error
- func (s *BinaryEncoder) WriteVectorStart(l int, isNil bool) error
- type Decoder
- type Encoder
- type RecordReader
- type RecordWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryDecoder ¶
type BinaryDecoder struct {
// contains filtered or unexported fields
}
BinaryDecoder reads binary encoded data from an underlying io.Reader. Binary data is read exactly the same way it is written. See BinaryEncoder for the format.
func NewBinaryDecoder ¶
func NewBinaryDecoder(r io.Reader) *BinaryDecoder
NewBinaryDecoder return a new BinaryDecoder wrapping an underlying io.Reader.
func (*BinaryDecoder) ReadBoolean ¶
func (d *BinaryDecoder) ReadBoolean() (bool, error)
ReadBoolean will read a byte and return `false` if the value is zero and `true` if the value is non-zero.
func (*BinaryDecoder) ReadBuffer ¶
func (d *BinaryDecoder) ReadBuffer() ([]byte, error)
ReadBuffer will read a byte slice first by reading the length encoded as an int (4 bytes) and then reading that number of bytes.
func (*BinaryDecoder) ReadByte ¶
func (d *BinaryDecoder) ReadByte() (byte, error)
ReadByte will read a single byte.
func (*BinaryDecoder) ReadDouble ¶
func (d *BinaryDecoder) ReadDouble() (float64, error)
ReadDouble will read a 64-bit float in IEEE 754 binary representation.
func (*BinaryDecoder) ReadEnd ¶
func (d *BinaryDecoder) ReadEnd() error
ReadEnd performs no operation in BinaryDecoder.
func (*BinaryDecoder) ReadFloat ¶
func (d *BinaryDecoder) ReadFloat() (float32, error)
ReadFloat will read a 32-bit float in IEEE 754 binary representation.
func (*BinaryDecoder) ReadInt ¶
func (d *BinaryDecoder) ReadInt() (int32, error)
ReadInt will read 4 bytes in big endian byte order.
func (*BinaryDecoder) ReadLong ¶
func (d *BinaryDecoder) ReadLong() (int64, error)
ReadLong will read 8 bytes in a big endian byte order.
func (*BinaryDecoder) ReadMapEnd ¶
func (d *BinaryDecoder) ReadMapEnd() error
ReadMapEnd performs no operation for BinaryDecoder.
func (*BinaryDecoder) ReadMapStart ¶
func (d *BinaryDecoder) ReadMapStart() (int, error)
ReadMapStart will read for the length of the map as an int (4 bytes) and return the map size. The caller should then decode the key and value for each item in the map.
func (*BinaryDecoder) ReadRecord ¶
func (d *BinaryDecoder) ReadRecord(r RecordReader) error
ReadRecord will read a jute record/class.
func (*BinaryDecoder) ReadStart ¶
func (d *BinaryDecoder) ReadStart() error
ReadStart performs no operation in BinaryDecoder.
func (*BinaryDecoder) ReadString ¶ added in v0.0.5
func (d *BinaryDecoder) ReadString() (string, error)
ReadString will read a utf-8 encoded string first by reading the length encoded as an int (4 bytes) and then reading that number of bytes.
func (*BinaryDecoder) ReadVectorEnd ¶
func (d *BinaryDecoder) ReadVectorEnd() error
ReadVectorEnd performs no operation for BinaryDecoder.
func (*BinaryDecoder) ReadVectorStart ¶
func (d *BinaryDecoder) ReadVectorStart() (int, error)
ReadVectorStart will read for the length of the vector as an int (4 bytes) and return the vector size. The caller should then decode each item for that vector.
type BinaryEncoder ¶
type BinaryEncoder struct {
// contains filtered or unexported fields
}
BinaryEncoder writes binary encoded data to an underlying io.Writer. Binary data is encoded in big endian with all bytes.
- `bool` will write out 1 bytes with `0` meaning `false` and `1` meaning `true`.
- `byte`, `int`, and `long\ are written out in bigendian byte order writing out 1, 4, and 8 bytes respectively.
- `float` and `double` are encoded as IEEE 754 as 4 or 8 bytes
- `ustring` and `buffer` write out the length encoded as an int (4 bytes) followed by the string/buffer in bytes
- `vector` will write the number of items as an int (4 bytes) followed by each item encoded in it's type.
- `map` will write the number of items as an int (4 bytes) followd by each key and value encoded in it's own type.
There is no header/tailer for the record itself.
func NewBinaryEncoder ¶
func NewBinaryEncoder(w io.Writer) *BinaryEncoder
NewBinaryEncoder return a new BinaryEncoder wrapping an underlying io.Writer.
func (*BinaryEncoder) Encode ¶
func (s *BinaryEncoder) Encode(r RecordWriter) error
func (*BinaryEncoder) WriteBoolean ¶
func (s *BinaryEncoder) WriteBoolean(b bool) error
WriteBoolean will write a boolean value as a single byte: `1` for `true`, `0` for `false`.
func (*BinaryEncoder) WriteBuffer ¶
func (s *BinaryEncoder) WriteBuffer(v []byte) error
WriteBuffer will write any byte slice by first writing it's length as 4 bytes followed by the bytes in the slice.
func (*BinaryEncoder) WriteByte ¶
func (s *BinaryEncoder) WriteByte(b byte) error
WriteByte will write a single byte.
func (*BinaryEncoder) WriteDouble ¶
func (s *BinaryEncoder) WriteDouble(i float64) error
WriteDouble will write a double value in IEEE 754 format as 8 bytes.
func (*BinaryEncoder) WriteEnd ¶
func (s *BinaryEncoder) WriteEnd() error
WriteEnd marks the endof the encoded record/class and flush it to the writer.
func (*BinaryEncoder) WriteFloat ¶
func (s *BinaryEncoder) WriteFloat(i float32) error
WriteFloat will write a Float in IEEE 754 format as 4 bytes.
func (*BinaryEncoder) WriteInt ¶
func (s *BinaryEncoder) WriteInt(i int32) error
WriteInt will write an int as 4 bytes in big endian byte order.
func (*BinaryEncoder) WriteLong ¶
func (s *BinaryEncoder) WriteLong(i int64) error
WriteLong will write a long as 8 bytes in big endian byte order.
func (*BinaryEncoder) WriteMapEnd ¶
func (s *BinaryEncoder) WriteMapEnd() error
WriteMapEnd will mark the end of a vector. In BinaryEncoder this performs no operation.
func (*BinaryEncoder) WriteMapStart ¶
func (s *BinaryEncoder) WriteMapStart(l int) error
WriteMapStart will write out the number of items in the map as 4 bytes. After calling Write<apStart the caller should write out each key and value of each item.
func (*BinaryEncoder) WriteRecord ¶
func (s *BinaryEncoder) WriteRecord(r RecordWriter) error
WriteRecord will write a jute record/class.
func (*BinaryEncoder) WriteStart ¶
func (s *BinaryEncoder) WriteStart() error
WriteStart marks the start of the encoded record/class. In BinaryEncoder this performs no operation.
func (*BinaryEncoder) WriteString ¶ added in v0.0.5
func (s *BinaryEncoder) WriteString(v string) error
WriteString will write a utf8 encoded string by first writing it's length as 4 bytes and then the byte of the string.
func (*BinaryEncoder) WriteVectorEnd ¶
func (s *BinaryEncoder) WriteVectorEnd() error
WriteVectorEnd will mark the end of a vector. In BinaryEncoder this performs no operation.
func (*BinaryEncoder) WriteVectorStart ¶
func (s *BinaryEncoder) WriteVectorStart(l int, isNil bool) error
WriteVectorStart will write out the number of items in the vector as 4 bytes. After calling WriteVectorStart the caller should write out each item.
type Decoder ¶
type Decoder interface { ReadStart() error ReadEnd() error ReadByte() (byte, error) ReadBoolean() (bool, error) ReadInt() (int32, error) ReadLong() (int64, error) ReadFloat() (float32, error) ReadDouble() (float64, error) ReadString() (string, error) ReadBuffer() ([]byte, error) ReadVectorStart() (int, error) ReadVectorEnd() error ReadMapStart() (int, error) ReadMapEnd() error ReadRecord(RecordReader) error }
Decoder defines how to dencode a record from a source like a network socket.
type Encoder ¶
type Encoder interface { WriteStart() error WriteEnd() error WriteByte(byte) error WriteBoolean(bool) error WriteInt(int32) error WriteLong(int64) error WriteFloat(float32) error WriteDouble(float64) error WriteString(string) error WriteBuffer([]byte) error WriteVectorStart(len int, isNil bool) error WriteVectorEnd() error WriteMapStart(len int) error WriteMapEnd() error WriteRecord(RecordWriter) error }
Encoder defines how to encode a record to a destination like a network socket.
type RecordReader ¶
RecordReader defines how a jute record (class) will be read from an decoder protocol
type RecordWriter ¶
RecordWriter defines how a jute record (class) will write to an encoder protocol.