Skip to main content

InlineEncoding

Trait InlineEncoding 

Source
pub trait InlineEncoding:
    MetaDescribe
    + Sized
    + 'static {
    type ValidationError;
    type Encoding;

    // Provided methods
    fn validate(
        value: Inline<Self>,
    ) -> Result<Inline<Self>, Self::ValidationError> { ... }
    fn inline_from<T: IntoInline<Self>>(t: T) -> Inline<Self> { ... }
    fn inline_try_from<T: TryToInline<Self>>(
        t: T,
    ) -> Result<Inline<Self>, <T as TryToInline<Self>>::Error> { ... }
    fn to_encoded(form: Inline<Self>) -> Encoded<Self> { ... }
}
Expand description

A trait that represents an abstract schema type that can be (de)serialized as a Inline.

This trait is usually implemented on a type-level empty struct, but may contain additional information about the schema type as associated constants or types. The Handle type for example contains type information about the hash algorithm, and the schema of the referenced blob.

See the value module for more information. See the BlobEncoding trait for the counterpart trait for blobs.

Required Associated Types§

Source

type ValidationError

The error type returned by validate. Use () or Infallible when every bit pattern is valid.

Source

type Encoding

The trait parameter to dispatch via for entity!{} field conversion. For inline schemas (32-byte data lives in the trible), set Encoding = Self — sources convert via IntoEncoded<Self> { Output = Inline<Self> }. For Handle<T>, set Encoding = T — sources convert via IntoEncoded<T> { Output = Blob<T> }. The BlobEncoding T sitting directly at trait position 0 is what lets downstream impl IntoEncoded<MyBlob> for MyType without bumping into the orphan rule.

Provided Methods§

Source

fn validate(value: Inline<Self>) -> Result<Inline<Self>, Self::ValidationError>

Check if the given value conforms to this schema.

Source

fn inline_from<T: IntoInline<Self>>(t: T) -> Inline<Self>

Create a new value from a concrete Rust type via IntoInline. Panics if the underlying conversion panics.

Source

fn inline_try_from<T: TryToInline<Self>>( t: T, ) -> Result<Inline<Self>, <T as TryToInline<Self>>::Error>

Create a new value from a concrete Rust type via TryToInline. Returns an error if the conversion fails.

Source

fn to_encoded(form: Inline<Self>) -> Encoded<Self>

Lift an already-encoded Inline<Self> into the Encoded sum entity!{} consumes — yields Encoded::Inline(form), no side-blob.

Overridable if a schema has unusual storage semantics. The blob-path counterpart lives on BlobEncoding::to_encoded.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl InlineEncoding for Boolean

Source§

impl InlineEncoding for ED25519PublicKey

Source§

impl InlineEncoding for ED25519RComponent

Source§

impl InlineEncoding for ED25519SComponent

Source§

impl InlineEncoding for F64

Source§

impl InlineEncoding for F256BE

Source§

impl InlineEncoding for F256LE

Source§

impl InlineEncoding for GenId

Source§

impl InlineEncoding for I256BE

Source§

impl InlineEncoding for I256LE

Source§

impl InlineEncoding for U256BE

Source§

impl InlineEncoding for U256LE

Source§

impl InlineEncoding for LineLocation

Source§

impl InlineEncoding for R256BE

Source§

impl InlineEncoding for R256LE

Source§

impl InlineEncoding for RangeInclusiveU128

Source§

impl InlineEncoding for RangeU128

Source§

impl InlineEncoding for ShortString

Source§

impl InlineEncoding for UnknownInline

Source§

impl InlineEncoding for NsDuration

Source§

impl InlineEncoding for NsTAIInterval

Source§

impl<H> InlineEncoding for Hash<H>
where H: HashProtocol,

Source§

impl<T: BlobEncoding + MetaDescribe> InlineEncoding for Handle<T>