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§
Sourcetype ValidationError
type ValidationError
The error type returned by validate.
Use () or Infallible when every bit pattern is valid.
Sourcetype Encoding
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§
Sourcefn validate(value: Inline<Self>) -> Result<Inline<Self>, Self::ValidationError>
fn validate(value: Inline<Self>) -> Result<Inline<Self>, Self::ValidationError>
Check if the given value conforms to this schema.
Sourcefn inline_from<T: IntoInline<Self>>(t: T) -> Inline<Self>
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.
Sourcefn inline_try_from<T: TryToInline<Self>>(
t: T,
) -> Result<Inline<Self>, <T as TryToInline<Self>>::Error>
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.
Sourcefn to_encoded(form: Inline<Self>) -> Encoded<Self>
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.