Documentation
¶
Overview ¶
Package encoding provides utilities to marshal and unmarshal some values to and from a binary stream suitable for the pesit protocol.
Index ¶
- Variables
- func MarshalUint16(number uint16) ([]byte, error)
- func MarshalUint24(number uint32) ([]byte, error)
- func MarshalUint32(number uint32) ([]byte, error)
- func MarshalUint64(number uint64) ([]byte, error)
- func UnmarshalUint16(bytes []byte) (uint16, error)
- func UnmarshalUint24(bytes []byte) (uint32, error)
- func UnmarshalUint32(bytes []byte) (uint32, error)
- func UnmarshalUint64(bytes []byte) (uint64, error)
Constants ¶
This section is empty.
Variables ¶
ErrInvalidConversion is the error returned when the slice to marshal has an invalid length.
Functions ¶
func MarshalUint16 ¶
MarshalUint16 serializes a unint16 number to a byte slice. The most significant byte is the first byte. If the first byte value is 0, it is removed (i.e. the byte slice have length 1).
The return value error is always nil.
func MarshalUint24 ¶
MarshalUint24 serializes a unint number to a byte slice. The most significant byte is the first byte. If the first byte value is 0, it is removed (i.e. the byte slice have length 1).
The return value error is always nil.
func MarshalUint32 ¶
MarshalUint32 serializes a unint number to a byte slice. The most significant byte is the first byte. If the first byte value is 0, it is removed (i.e. the byte slice have length 1).
The return value error is always nil.
func MarshalUint64 ¶
MarshalUint64 serializes a unint number to a byte slice. The most significant byte is the first byte. If the first byte value is 0, it is removed (i.e. the byte slice have length 1).
The return value error is always nil.
func UnmarshalUint16 ¶
UnmarshalUint16 reads a byte slice in a uint16 number. The slice must contain 1 or 2 bytes, the most significant byte being the first byte. It returns an error if the slice has the wrong length.
func UnmarshalUint24 ¶
UnmarshalUint24 reads a byte slice in a uint number. The slice must contain 1, 2 or 3 bytes, the most significant byte being the first byte. It returns an error if the slice has the wrong length.
func UnmarshalUint32 ¶
UnmarshalUint32 reads a byte slice in a uint number. The slice must contain 1, 2, 3 or 4 bytes, the most significant byte being the first byte. It returns an error if the slice has the wrong length.
Types ¶
This section is empty.
Source Files
¶
- doc.go
- uint.go
- uint16.go
- uint24.go
- uint32.go
- uint64.go