Documentation ¶
Overview ¶
Package encoding is for utilities relating to the encoding package from the stdlib
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinaryUnmarshalCallback ¶
func BinaryUnmarshalCallback[T encoding.BinaryUnmarshaler](newFn func() T, callback func(T, error)) func(buf []byte)
BinaryUnmarshalCallback returns a function that will decode the argument byte slice into T using `newFn` to create an instance of T and the encoding.BinaryUnmarshaler interface to do the actual conversion. `callback` will be called with the resulting T. If the argument byte slice is empty, callback will be called with `nil`. Unmarshalling errors will be provided to the callback as the second argument. The data argument to the callback may still be non-nil even if there was an error. This allows the callback to handle the allocated object, even in the face of errors.
Types ¶
This section is empty.