Documentation
¶
Index ¶
- func MarshalBool(v bool, bs []byte) int
- func MarshalMap[T comparable, V any](v map[T]V, m1 mus.Marshaller[T], m2 mus.Marshaller[V], bs []byte) (n int)
- func MarshalPtr[T any](v *T, m mus.Marshaller[T], bs []byte) (n int)
- func MarshalSlice[T any](v []T, m mus.Marshaller[T], bs []byte) (n int)
- func MarshalString(v string, bs []byte) (n int)
- func SizeBool(v bool) (n int)
- func SizeMap[T comparable, V any](v map[T]V, s1 mus.Sizer[T], s2 mus.Sizer[V]) (size int)
- func SizePtr[T any](v *T, s mus.Sizer[T]) (size int)
- func SizeSlice[T any](v []T, s mus.Sizer[T]) (size int)
- func SizeString(v string) (n int)
- func SkipBool(bs []byte) (n int, err error)
- func SkipMap(sk1, sk2 mus.Skipper, bs []byte) (n int, err error)
- func SkipPtr(sk mus.Skipper, bs []byte) (n int, err error)
- func SkipSlice(sk mus.Skipper, bs []byte) (n int, err error)
- func SkipString(bs []byte) (n int, err error)
- func UnmarshalBool(bs []byte) (v bool, n int, err error)
- func UnmarshalMap[T comparable, V any](u1 mus.Unmarshaller[T], u2 mus.Unmarshaller[V], bs []byte) (v map[T]V, n int, err error)
- func UnmarshalPtr[T any](u mus.Unmarshaller[T], bs []byte) (v *T, n int, err error)
- func UnmarshalSlice[T any](u mus.Unmarshaller[T], bs []byte) (v []T, n int, err error)
- func UnmarshalString(bs []byte) (v string, n int, err error)
- func UnmarshalValidMap[T comparable, V any](lenVl com.Validator[int], u1 mus.Unmarshaller[T], u2 mus.Unmarshaller[V], ...) (v map[T]V, n int, err error)
- func UnmarshalValidSlice[T any](lenVl com.Validator[int], u mus.Unmarshaller[T], vl com.Validator[T], ...) (v []T, n int, err error)
- func UnmarshalValidString(lenVl com.Validator[int], skip bool, bs []byte) (v string, n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalBool ¶
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 ¶
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 ¶
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 ¶
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 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 ¶
SizePtr returns the size of a MUS-encoded pointer.
The s argument specifies the Sizer for the pointer base type.
func SizeSlice ¶
SizeSlice returns the size of a MUS-encoded slice value.
The s argument specifies the Sizer for the slice elements.
func SizeString ¶
SizeString returns the size of a MUS-encoded string value.
func SkipBool ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.