Documentation ¶
Index ¶
- Variables
- func HashEqual(a Hash, b TypeValue) bool
- func RegisterHash(id uint64, f func() (Hash, error))
- type Hash
- type TypeValue
- func (t TypeValue) Equal(other TypeValue) bool
- func (s *TypeValue) MarshalBinary() ([]byte, error)
- func (s *TypeValue) MarshalText() ([]byte, error)
- func (t *TypeValue) ReadFrom(r io.Reader) (n int64, err error)
- func (t TypeValue) String() string
- func (s *TypeValue) UnmarshalBinary(data []byte) error
- func (s *TypeValue) UnmarshalText(text []byte) error
- func (t *TypeValue) WriteTo(w io.Writer) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrHashNotFound = errors.New("hash type not found")
)
var ( // ErrValueTooBig is returned when value byte size exceeds limit // set by MaxValueSize. ErrValueTooBig = errors.New("yamf: value is too big") )
var ( // MaxValueSize sets the maximal value byte size for read operations. // Less than zero means no limit. MaxValueSize = 1024 )
Functions ¶
func HashEqual ¶
HashEqual is a handy function to compare a Hash object's sum to a sum stored in TypeValue.
func RegisterHash ¶
RegisterHash associates factory function with an hash type identifier. If a given type id exists, the function will be overwritten.
RegisterHash can be called concurrently.
Types ¶
type Hash ¶
func CreateHash ¶
CreateHash creates hash object associated with given type id and an error, if any.
CreateHash can be called concurrently.
func TypeValueToHash ¶
type TypeValue ¶
type TypeValue struct { Type uint64 Value []byte io.ReaderFrom io.WriterTo encoding.BinaryMarshaler encoding.BinaryUnmarshaler encoding.TextMarshaler encoding.TextUnmarshaler }
TypeValue encapsulates type and value pair and allows to encode and decode them as per Simple Type-Length-Value specification:
https://github.com/AljoschaMeyer/stlv
func HashToTypeValue ¶
func (*TypeValue) MarshalBinary ¶
MarshalBinary encodes receiver into a byte slice and returns an error, if any.
func (*TypeValue) MarshalText ¶
MarshalText encodes receiver into a textual representation and returns an error, if any.
func (*TypeValue) ReadFrom ¶
MarshalBinary encodes receiver into a byte slice and returns an error, if any.
varu64.ErrNonCanonical may be returned in the case when non-canonical encoding was encountered during the process.
func (*TypeValue) UnmarshalBinary ¶
UnmarshalBinary decodes data into the receiver and returns an error, if any.
func (*TypeValue) UnmarshalText ¶
UnmarshalText decodes textual representation into the receiver and returns an error, if any.