Documentation ¶
Overview ¶
Package containing the types and errors used by all other packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var VarintMinimumSizeError = errors.New("varint not encoded with minimum size")
Number encoded as varint does not use minimum bytes for representation.
Functions ¶
func DeserializeTo ¶
func DeserializeTo(to Serializer, raw []byte) error
A common function for deserializing a byte array into an instance of the object using the defined DeserializeReader method.
Types ¶
type DeserializeFailedError ¶
type DeserializeFailedError string
Deserialization of an object failed. Used by Deserialize and DeserializeReader methods of the NetworkSerializer interface.
func (DeserializeFailedError) Error ¶
func (e DeserializeFailedError) Error() string
type NotEnoughBytesError ¶
type NotEnoughBytesError int
Read failed because of not enough bytes.
func (NotEnoughBytesError) Error ¶
func (e NotEnoughBytesError) Error() string
type Serializer ¶
type Serializer interface { // Serialize the object into bytes Serialize() []byte // Deserialize the object from io.Reader DeserializeReader(io.Reader) error }
Interface defined for every message and serializable type.
type Varint ¶
type Varint uint64
Integer can be encoded depending on the represented value to save space. Variable length integers always precede an array/vector of a type of data that may vary in length. Varints MUST use the minimum possible number of bytes to encode a value.
For example: the value 6 can be encoded with one byte therefore a varint that uses three bytes to encode the value 6 is malformed and the decoding task must be aborted.
type VarintList ¶
type VarintList []Varint
n integers can be stored using n+1 variable length integers where the first var_int equals n.
func (*VarintList) DeserializeReader ¶
func (i *VarintList) DeserializeReader(b io.Reader) error
func (VarintList) Serialize ¶
func (i VarintList) Serialize() []byte