Trait VirtualDynExtension

Source
pub trait VirtualDynExtension<Discriminant: DiscriminantTag = ()>: Default {
    type TypesVia: VirtualDynExtensionSchema<Discriminant>;

    // Required methods
    fn access(
        &self,
    ) -> <Self::TypesVia as VirtualDynExtensionSchema<Discriminant>>::Repr;
    fn mutate(
        &mut self,
        v: <Self::TypesVia as VirtualDynExtensionSchema<Discriminant>>::Repr,
    );

    // Provided methods
    fn len(&self) -> usize { ... }
    fn min(&self) -> usize { ... }
    fn max(&self) -> usize { ... }
}
Expand description

Allocation interface for virtual extensions whose type and schema are defined externally.

This is a second-order abstraction over VirtualDynField: instead of defining its own element type, the field delegates both type and representation to an external schema.

§Context

In the virtual system:

This allows a container (Self) to host fields whose types are:

  • not known at implementation time
  • supplied later via type-level composition

§Representation

All operations are performed on the schema-defined representation:

  • TypesVia defines None, Some, Many, and Repr
  • Many is expected to have vector-like semantics
  • size and bounds are resolved dynamically (within constraints)

§Semantics

  • Container (Self)

    • owns storage
  • Schema (TypesVia)

    • defines element type and representation

This enables fields to remain fully generic over externally defined and deferred types.

§Key Property

Type and structure are not fixed in the container, but injected externally and resolved at compile time.

§Default Discriminant

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

Required Associated Types§

Source

type TypesVia: VirtualDynExtensionSchema<Discriminant>

External schema defining the extension.

Required Methods§

Source

fn access( &self, ) -> <Self::TypesVia as VirtualDynExtensionSchema<Discriminant>>::Repr

Returns the underlying representation.

Source

fn mutate( &mut self, v: <Self::TypesVia as VirtualDynExtensionSchema<Discriminant>>::Repr, )

Replaces the underlying representation.

Provided Methods§

Source

fn len(&self) -> usize

Returns the current number of elements.

Source

fn min(&self) -> usize

Returns the minimum number of elements representable.

Source

fn max(&self) -> 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§