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:
VirtualDynFielddefines fields with internally known typesVirtualDynExtensionSchemadefines externally supplied types and layoutVirtualDynExtensionstores values using that schema
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:
TypesViadefinesNone,Some,Many, andReprManyis 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§
Sourcetype TypesVia: VirtualDynExtensionSchema<Discriminant>
type TypesVia: VirtualDynExtensionSchema<Discriminant>
External schema defining the extension.
Required Methods§
Sourcefn access(
&self,
) -> <Self::TypesVia as VirtualDynExtensionSchema<Discriminant>>::Repr
fn access( &self, ) -> <Self::TypesVia as VirtualDynExtensionSchema<Discriminant>>::Repr
Returns the underlying representation.
Sourcefn mutate(
&mut self,
v: <Self::TypesVia as VirtualDynExtensionSchema<Discriminant>>::Repr,
)
fn mutate( &mut self, v: <Self::TypesVia as VirtualDynExtensionSchema<Discriminant>>::Repr, )
Replaces the underlying representation.
Provided Methods§
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.