Trait VirtualDynExtensionSchema

Source
pub trait VirtualDynExtensionSchema<Discriminant: DiscriminantTag = ()> {
    type None: Delimited;
    type Some: Delimited;
    type Many: Buffer<Self::Some> + Indexable<Self::Some>;
    type Repr: Delimited + Default + FromTag<Self::None, NoneTag> + TryIntoTag<Self::None, NoneTag> + FromTag<Self::Some, SomeTag> + TryIntoTag<Self::Some, SomeTag> + TryFromTag<Self::Many, ManyTag> + IntoTag<Self::Many, ManyTag>;

    // Required methods
    fn len(v: &Self::Repr) -> usize;
    fn min(v: &Self::Repr) -> usize;
    fn max(v: &Self::Repr) -> usize;
}
Expand description

Defines the schema for a VirtualDynExtension identified by a Discriminant.

A VirtualDynExtensionSchema describes the structure and representation of an extension field whose type is supplied externally.

Unlike VirtualDynField, the element type and layout are not defined by the container, but provided through this schema.

§Context

In the virtual system:

  • VirtualDynField defines fields with internally known types
  • VirtualDynExtensionSchema defines fields with externally supplied types
  • VirtualDynExtension stores values using this schema

This allows containers to support fields whose types are:

  • not known at implementation time
  • injected via type-level composition

§Representation

The Many form is expected to have vector-like semantics:

  • dynamically sized (within bounds)
  • supports buffering and indexed access

The schema itself is purely type-level:

  • it does not store data
  • it defines how data is represented and interpreted

§Discriminant

The Discriminant links:

  • the extension storage
  • to its schema

allowing multiple independent extensions to coexist safely.

§Default Discriminant

  • Discriminant = (): defines a single default extension schema, meaning only one extension is assumed.

Required Associated Types§

Source

type None: Delimited

Representation of absence.

Source

type Some: Delimited

The logical element type defined by the schema.

This type is externally supplied.

Source

type Many: Buffer<Self::Some> + Indexable<Self::Some>

A collection of Some with vector-like semantics.

Source

type Repr: Delimited + Default + FromTag<Self::None, NoneTag> + TryIntoTag<Self::None, NoneTag> + FromTag<Self::Some, SomeTag> + TryIntoTag<Self::Some, SomeTag> + TryFromTag<Self::Many, ManyTag> + IntoTag<Self::Many, ManyTag>

Opaque representation of the extension.

Encodes None, Some, or Many and supports tagged conversions.

Required Methods§

Source

fn len(v: &Self::Repr) -> usize

Returns the number of elements encoded in the representation.

Source

fn min(v: &Self::Repr) -> usize

Returns the minimum number of elements representable.

Source

fn max(v: &Self::Repr) -> usize

Returns the maximum number of elements representable.

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§