Skip to main content

ErasedComponent

Trait ErasedComponent 

Source
pub trait ErasedComponent:
    Send
    + Sync
    + 'static {
    // Required methods
    fn id(&self) -> ComponentId;
    fn component_type(&self) -> ComponentType;
    fn apply_update_payload(
        &self,
        payload: &[u8],
        prior: Option<&[u8]>,
    ) -> Result<Vec<u8>, ComponentTypedError>;
    fn expand_to_changes(
        &self,
        op: &AppDataUpdateOperation,
        prior: Option<&[u8]>,
    ) -> Result<Vec<ExpandedComponentChange>, ComponentTypedError>;
    fn validate_invariant(
        &self,
        change: &ComponentChange<'_>,
        registry: &ComponentRegistry,
    ) -> Result<(), ComponentInvariantError>;
}
Expand description

Object-safe view of a Component impl, for runtime dispatch via &'static dyn ErasedComponent. Carries only the byte-shaped methods — typed reads through decode_value / encode_value / encode_mutation need the static Self::Value / Self::Mutation types and aren’t reachable through the dyn boundary.

A blanket impl over C: Component makes every concrete Component impl auto-implement this trait.

Required Methods§

Source

fn id(&self) -> ComponentId

The component this impl handles — equivalent to C::ID.

Source

fn component_type(&self) -> ComponentType

The wire type — equivalent to C::COMPONENT_TYPE.

Source

fn apply_update_payload( &self, payload: &[u8], prior: Option<&[u8]>, ) -> Result<Vec<u8>, ComponentTypedError>

Source

fn expand_to_changes( &self, op: &AppDataUpdateOperation, prior: Option<&[u8]>, ) -> Result<Vec<ExpandedComponentChange>, ComponentTypedError>

Source

fn validate_invariant( &self, change: &ComponentChange<'_>, registry: &ComponentRegistry, ) -> Result<(), ComponentInvariantError>

Implementors§