Skip to main content

ComponentStore

Trait ComponentStore 

Source
pub trait ComponentStore {
    // Required methods
    fn get<'life0, 'life1, 'async_trait, C>(
        &'life0 self,
        id: &'life1 Id,
    ) -> Pin<Box<dyn Future<Output = Option<C>> + 'async_trait>>
       where C: 'async_trait + Component,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set<'life0, 'life1, 'async_trait, C>(
        &'life0 self,
        id: &'life1 Id,
        value: C,
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
       where C: 'async_trait + Component,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove<'life0, 'life1, 'async_trait, C>(
        &'life0 self,
        id: &'life1 Id,
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
       where C: 'async_trait + Component,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list<'life0, 'async_trait, C>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Vec<(Id, C)>> + 'async_trait>>
       where C: 'async_trait + Component,
             Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Capability-keyed component access (spec §3/§7), ECS/column-store style: read, write, or detach one capability at a time, keyed by task Id. There is no whole-task load/save — a caller (or a guard) touches only the capabilities it needs. Generic methods make this not object-safe, so callers hold a concrete store (Services<St>), not &dyn.

ponytail: per-capability reads/writes inside a command mean a command is not one snapshot-in / one-save-out. Single-user/embedded is fine; wrap a command’s reads+writes in a transaction at M2 (Turso) if concurrency demands it.

Required Methods§

Source

fn get<'life0, 'life1, 'async_trait, C>( &'life0 self, id: &'life1 Id, ) -> Pin<Box<dyn Future<Output = Option<C>> + 'async_trait>>
where C: 'async_trait + Component, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The task’s C component, or None if it doesn’t carry that capability.

Source

fn set<'life0, 'life1, 'async_trait, C>( &'life0 self, id: &'life1 Id, value: C, ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
where C: 'async_trait + Component, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Attach/overwrite the task’s C component.

Source

fn remove<'life0, 'life1, 'async_trait, C>( &'life0 self, id: &'life1 Id, ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
where C: 'async_trait + Component, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Detach the task’s C component (absent ⇒ no-op).

Source

fn list<'life0, 'async_trait, C>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<(Id, C)>> + 'async_trait>>
where C: 'async_trait + Component, Self: 'async_trait, 'life0: 'async_trait,

All tasks carrying C, with the component. Presence is the capability.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§