Trait saltpig::extensions::Extension [−][src]
The extension trait.
This trait marks types which are extensions. Each extension type T
knows
four things:
- What CBOR tag belongs to it
- How to convert a
T
into aValue
- How to tell whether a given
Value
represents a validT
- How to convert a
Value
that represents aT
into an actualT
These are enforced by the Into<Value>
and TryFrom<Value>
bounds, and the
TAG
associated const.
Normally, a Value
represents a T
if it is a Tagged
and the tag
matches T::TAG
, with its classification as representing a valid T
conditional on the inner value conforming to some specific structure (for
example, to be a valid Uuid
, a value with tag 37
must be a byte
string with length 16
).
Extension types are expected to meet saltpig
's ergonomic standards. For
example, an extension type representing a bignum should implement standard
conversions from and to the relevant bignum type (as well as the required
conversions from and to Value
).
Examples
Each of the submodules is an example. extensions::uuid
is a nice and
simple one.
Associated Constants
Implementors
impl Extension for EncodedCbor
impl Extension for Ident