Documentation
¶
Overview ¶
Package encoding provides encoding utilities.
Index ¶
- Variables
- func Concat(a, b []byte) []byte
- func Concat3(a, b, c []byte) []byte
- func Concatenate(input ...[]byte) []byte
- func DecodeLongVector(in []byte, out ...*[]byte) error
- func DecodeVector(in []byte) (data []byte, offset int, err error)
- func EncodeVector(input []byte) []byte
- func EncodeVectorLen(input []byte, length uint16) []byte
- func I2OSP(value int, length uint16) []byte
- func OS2IP(input []byte) int
- func SuffixString(a []byte, b string) []byte
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDecoding indicates a decoding error. ErrDecoding = errors.New("decoding error") // ErrHeaderLength indicates that the header length is insufficient for decoding. ErrHeaderLength = errors.New("insufficient header length for decoding") // ErrTotalLength indicates that the total length is insufficient for decoding. ErrTotalLength = errors.New("insufficient total length for decoding") // ErrMissingOutput indicates that no output slice was provided for decoding. ErrMissingOutput = errors.New("missing output slice for decoding") // ErrNilOutput indicates that a nil output slice was provided for decoding. ErrNilOutput = errors.New("nil output slice for decoding") // ErrEmptyEncoded indicates that the decoding returned empty data. ErrEmptyEncoded = errors.New("decoding yielded empty data") )
Encoding/decoding errors.
View Source
var ( // ErrInputNegative happens when the provider integer is negative. ErrInputNegative = errors.New("negative input") // ErrInputLarge happens when the provider value is too large for the specified length. ErrInputLarge = errors.New("input value is too high for length") // ErrLengthNegativeOrZero happens when the specified length is negative or 0. ErrLengthNegativeOrZero = errors.New("length is negative or 0") // ErrLengthTooBig happens when the specified length is > 4. ErrLengthTooBig = errors.New("requested length is > 4") // ErrInputEmpty happens when the input is nil or empty. ErrInputEmpty = errors.New("nil or empty input") // ErrInputTooLarge happens when the input is longer than 4 bytes. ErrInputTooLarge = errors.New("input too large for integer") )
I2OSP/OS2IP errors.
Functions ¶
func Concatenate ¶ added in v0.10.0
Concatenate takes the variadic array of input and returns a concatenation of it.
func DecodeLongVector ¶ added in v0.10.0
DecodeLongVector decodes a vector of concatenated 2-byte length-prefixed byte slices, and stores the encoded slices in the provided output slice.
func DecodeVector ¶ added in v0.10.0
DecodeVector returns the byte-slice of length indexed in the first two bytes.
func EncodeVector ¶ added in v0.10.0
EncodeVector returns the input with a two-byte encoding of its length.
func EncodeVectorLen ¶ added in v0.10.0
EncodeVectorLen returns the input prepended with a byte encoding of its length.
func SuffixString ¶ added in v0.10.0
SuffixString returns the concatenation of the input byte string and the string argument.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.