Skip to main content

VeritType

Trait VeritType 

Source
pub trait VeritType: Sized {
    const VERIT_NAME: &'static str;
    const VERIT_MODE: StructMode;

    // Required methods
    fn verit_register(
        builder: SchemaBuilder,
        seen: &mut BTreeSet<&'static str>,
    ) -> SchemaBuilder;
    fn verit_pack(&self) -> Value;
    fn verit_unpack(reader: &StructReader<'_, '_>) -> Result<Self, Error>;
    fn verit_schema() -> &'static Schema;

    // Provided methods
    fn verit_schema_id() -> u128 { ... }
    fn to_verit(&self, mode: SchemaMode) -> Result<Vec<u8>, Error> { ... }
    fn from_verit(bytes: &[u8]) -> Result<Self, Error> { ... }
}
Expand description

Implemented by every #[derive(Verit)] type. All of it is generated; you never write an impl by hand. The provided methods (to_verit, from_verit, verit_schema_id) are the surface you actually call.

Required Associated Constants§

Source

const VERIT_NAME: &'static str

This type’s name in the generated schema (its Rust type name).

Source

const VERIT_MODE: StructMode

How this struct is stored on the wire (#[verit(mode = "…")]).

Required Methods§

Source

fn verit_register( builder: SchemaBuilder, seen: &mut BTreeSet<&'static str>, ) -> SchemaBuilder

Add this type’s struct definition — and, transitively, every nested VeritType it references — to builder, skipping any name already in seen. The derive generates this; it is the mechanism that lets one root type pull its whole type graph into a single schema.

Source

fn verit_pack(&self) -> Value

Pack self into a dynamic struct Value (the encoder’s input form).

Source

fn verit_unpack(reader: &StructReader<'_, '_>) -> Result<Self, Error>

Reconstruct Self from a dynamic StructReader over this type’s fields.

Source

fn verit_schema() -> &'static Schema

The process-wide Schema rooted at this type, built once and cached. Generated with a per-type OnceLock, so the schema (and its 128-bit id) is computed at most once per program run.

Provided Methods§

Source

fn verit_schema_id() -> u128

This type’s 128-bit schema id — the cross-language wire contract.

Source

fn to_verit(&self, mode: SchemaMode) -> Result<Vec<u8>, Error>

Encode self to Veritate bytes against this type’s schema. SchemaMode::Inline embeds the schema (self-describing, verit dump-able); SchemaMode::HashOnly writes just the 128-bit id.

Source

fn from_verit(bytes: &[u8]) -> Result<Self, Error>

Decode Self from bytes written against this same type’s schema (matching the Python decorator’s identity-resolver behaviour). To read bytes written by an evolved schema, resolve explicitly with Resolver::new and call verit_unpack.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§