Trait VirtualStaticExtension

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

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

Allocation interface for virtual extensions whose type and schema are defined externally and fully determined at compile time.

This is the static counterpart to VirtualDynExtension, where both type and structure are fixed via the schema.

§Context

In the static field model:

This allows a container (Self) to host externally defined fields with statically determined structure.

§Representation

All operations are performed on the schema-defined representation:

  • TypesVia defines None, Some, Many, and Repr
  • Many is expected to have array-like semantics
  • size and capacity are encoded at compile time

§Semantics

  • Container (Self)

    • owns storage
  • Schema (TypesVia)

    • defines element type and representation

§Key Property

Both type and structure are fully determined at compile time, enabling zero-overhead representations without dynamic checks.

§Default Discriminant

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

Required Associated Types§

Source

type TypesVia: VirtualStaticExtensionSchema<Discriminant>

External schema defining the extension.

Required Methods§

Source

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

Returns the underlying representation.

Source

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

Replaces the underlying representation.

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§