pub trait StateSubset<Parent: State>: State {
// Required methods
fn extract(parent: &Parent) -> Self;
fn map_update(update: Self::Update) -> Parent::Update;
}Expand description
Compile-time constraint for shared-state subgraph mode
This trait defines the relationship between a parent graph’s state and a subgraph’s state when they share state fields. It enables type-safe state transformation between parent and child graphs.
§Type Parameters
Parent- The parent graph’s state type
§Examples
ⓘ
use juncture_core::State;
struct ParentState {
name: String,
age: u32,
}
struct ChildState {
name: String,
}
impl StateSubset<ParentState> for ChildState {
fn extract(parent: &ParentState) -> Self {
Self { name: parent.name.clone() }
}
fn map_update(update: Self::Update) -> ParentState::Update {
// Map child update to parent update
ParentStateUpdate { name: update.name }
}
}Required Methods§
Sourcefn map_update(update: Self::Update) -> Parent::Update
fn map_update(update: Self::Update) -> Parent::Update
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".