Skip to main content

GraphState

Trait GraphState 

Source
pub trait GraphState:
    Sized
    + Send
    + Sync
    + 'static {
    type Update: Default + Send + 'static;

    // Required method
    fn apply(&mut self, update: Self::Update);

    // Provided method
    fn reset_ephemeral(&mut self) { ... }
}
Expand description

Trait implemented by structs that hold graph state. The Update type is generated by #[derive(GraphState)] and represents a partial delta; apply merges a delta into self via per-field reducers.

Required Associated Types§

Source

type Update: Default + Send + 'static

Per-field-reducer-aware delta type.

Required Methods§

Source

fn apply(&mut self, update: Self::Update)

Apply a delta to self.

Provided Methods§

Source

fn reset_ephemeral(&mut self)

Reset any #[reducer(ephemeral)] fields to Default::default(). The engine calls this at the start of every superstep, before running tasks — so ephemeral fields hold only writes from the current step. Default impl is a no-op for state types with no ephemeral fields.

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.

Implementations on Foreign Types§

Source§

impl GraphState for ()

Source§

type Update = ()

Source§

fn apply(&mut self, _: Self::Update)

Implementors§