ord

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalBool

func MarshalBool(v bool, bs []byte) int

MarshalBool fills bs with the MUS encoding of a bool value.

Returns the number of used bytes. It will panic if receives too small bs.

func MarshalMap

func MarshalMap[T comparable, V any](v map[T]V, m1 mus.Marshaller[T],
	m2 mus.Marshaller[V],
	bs []byte,
) (n int)

MarshalMap fills bs with the MUS encoding of a map value.

Arguments m1, m2 specify Marshallers for the keys and map values, respectively.

Returns the number of used bytes. It will panic if receives too small bs.

func MarshalPtr

func MarshalPtr[T any](v *T, m mus.Marshaller[T], bs []byte) (n int)

MarshalPtr fills bs with the MUS encoding of a pointer.

The m argument specifies the Marshaller for the pointer base type.

Returns the number of used bytes. It will panic if receives too small bs.

func MarshalSlice

func MarshalSlice[T any](v []T, m mus.Marshaller[T], bs []byte) (n int)

MarshalSlice fills bs with the MUS encoding of a slice value.

The m argument specifies the Marshaller for the slice elements.

Returns the number of used bytes. It will panic if receives too small bs.

func MarshalString

func MarshalString(v string, bs []byte) (n int)

MarshalString fills bs with the MUS encoding of a string value.

Returns the number of used bytes. It will panic if receives too small bs.

func SizeBool

func SizeBool(v bool) (n int)

SizeBool returns the size of a MUS-encoded bool value.

func SizeMap

func SizeMap[T comparable, V any](v map[T]V, s1 mus.Sizer[T],
	s2 mus.Sizer[V]) (size int)

SizeMap returns the size of a MUS-encoded map value.

Arguments s1, s2 specify Sizers for the keys and map values.

func SizePtr

func SizePtr[T any](v *T, s mus.Sizer[T]) (size int)

SizePtr returns the size of a MUS-encoded pointer.

The s argument specifies the Sizer for the pointer base type.

func SizeSlice

func SizeSlice[T any](v []T, s mus.Sizer[T]) (size int)

SizeSlice returns the size of a MUS-encoded slice value.

The s argument specifies the Sizer for the slice elements.

func SizeString

func SizeString(v string) (n int)

SizeString returns the size of a MUS-encoded string value.

func SkipBool

func SkipBool(bs []byte) (n int, err error)

SkipBool skips a MUS-encoded bool value.

In addition to the number of skipped bytes, it can also return mus.ErrTooSmallByteSlice or com.ErrWrongFormat.

func SkipMap

func SkipMap(sk1, sk2 mus.Skipper, bs []byte) (n int, err error)

SkipMap skips a MUS-encoded map value.

Arguments sk1, sk2 specify Skippers for the keys and map values, respectively.

In addition to the number of skipped bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrNegativeLength or Skipper error.

func SkipPtr

func SkipPtr(sk mus.Skipper, bs []byte) (n int, err error)

SkipPtr skips a MUS-encoded pointer.

The sk argument specifies the Skipper for the pointer base type.

In addition to the number of skipped bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrWrongFormat or Skipper error.

func SkipSlice

func SkipSlice(sk mus.Skipper, bs []byte) (n int, err error)

SkipSlice skips a MUS-encoded slice value.

The sk argument specifies the Skipper for the slice elements.

In addition to the number of skipped bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrOverflow, com.ErrNegativeLength or Skipper error.

func SkipString

func SkipString(bs []byte) (n int, err error)

SkipString skips a MUS-encoded string value.

In addition to the number of skipped bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrOverflow or mus.ErrNegativeLength.

func UnmarshalBool

func UnmarshalBool(bs []byte) (v bool, n int, err error)

UnmarshalBool parses a MUS-encoded bool value from bs.

In addition to the bool value and the number of used bytes, it can also return mus.ErrTooSmallByteSlice or com.ErrWrongFormat.

func UnmarshalMap

func UnmarshalMap[T comparable, V any](u1 mus.Unmarshaller[T],
	u2 mus.Unmarshaller[V],
	bs []byte,
) (v map[T]V, n int, err error)

UnmarshalMap parses a MUS-encoded map value from bs.

Arguments u1, u2 specify Unmarshallers for the keys and map values, respectively.

In addition to the map value and the number of used bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrOverflow, com.ErrNegativeLength or Unmarshaller error.

func UnmarshalPtr

func UnmarshalPtr[T any](u mus.Unmarshaller[T], bs []byte) (v *T, n int,
	err error)

UnmarshalPtr parses a MUS-encoded pointer from bs.

The u argument specifies the Unmarshaller for the base pointer type.

In addition to the pointer value and the number of used bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrWrongFormat or Unarshaller error.

func UnmarshalSlice

func UnmarshalSlice[T any](u mus.Unmarshaller[T], bs []byte) (v []T, n int,
	err error)

UnmarshalSlice parses a MUS-encoded slice value from bs.

The u argument specifies the Unmarshaller for the slice elements.

In addition to the slice value and the number of used bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrOverflow, com.ErrNegativeLength or Unmarshaller error.

func UnmarshalString

func UnmarshalString(bs []byte) (v string, n int, err error)

UnmarshalString parses a MUS-encoded string value from bs.

In addition to the string value and the number of used bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrOverflow or com.ErrNegativeLength.

func UnmarshalValidMap

func UnmarshalValidMap[T comparable, V any](lenVl com.Validator[int],
	u1 mus.Unmarshaller[T],
	u2 mus.Unmarshaller[V],
	vl1 com.Validator[T],
	vl2 com.Validator[V],
	sk1, sk2 mus.Skipper,
	bs []byte,
) (v map[T]V, n int, err error)

UnmarshalValidMap parses a MUS-encoded valid map value from bs.

The lenVl argument specifies the map length Validator, arguments u1, u2, vl1, vl2, sk1, sk2 - Unmarshallers, Validators and Skippers for the keys and map values, respectively. If one of the Validators returns an error, UnmarshalValidMap uses the Skippers to skip the remaining bytes of the map. If one of the Skippers is nil, it immediately returns a validation error.

In addition to the map value and the number of used bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrOverflow, com.ErrNegativeLength, Unmarshaller, Validator or Skipper error.

func UnmarshalValidSlice

func UnmarshalValidSlice[T any](lenVl com.Validator[int],
	u mus.Unmarshaller[T],
	vl com.Validator[T],
	sk mus.Skipper,
	bs []byte,
) (v []T, n int, err error)

UnmarshalValidSlice parses a MUS-encoded valid slice value from bs.

The lenVl argument specifies the slice length Validator, arguments u, vl, sk - Unmarshaller, Validator and Skipper for the slice elements. If one of the Validators returns an error, UnmarshalValidSlice uses the Skipper to skip the remaining bytes of the slice. If the value of the Skipper is nil, it immediately returns the validation error.

In addition to the slice value and the number of used bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrOverflow, com.ErrNegativeLength or Unmarshaller, Validator or Skipper error.

func UnmarshalValidString

func UnmarshalValidString(lenVl com.Validator[int], skip bool, bs []byte) (
	v string, n int, err error)

UnmarshalValidString parses a MUS-encoded valid string value from bs.

The lenVl argument specifies the string length Validator. If it returns an error and skip == true UnmarshalValidString skips the remaining bytes of the string.

In addition to the string value and the number of used bytes, it can also return mus.ErrTooSmallByteSlice, com.ErrOverflow, com.ErrNegativeLength or Validator error.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL