pub trait ContextAccess {
Show 16 methods
// Required methods
fn global(&self, idx: u32) -> &Value;
fn set_global(&mut self, idx: u32, value: Value);
fn visit_count(&self, id: DefinitionId) -> u32;
fn increment_visit(&mut self, id: DefinitionId);
fn set_visit_count(&mut self, id: DefinitionId, count: u32);
fn turn_count(&self, id: DefinitionId) -> Option<u32>;
fn set_turn_count(&mut self, id: DefinitionId, turn: u32);
fn turn_index(&self) -> u32;
fn increment_turn_index(&mut self);
fn set_turn_index(&mut self, index: u32);
fn rng_seed(&self) -> i32;
fn set_rng_seed(&mut self, seed: i32);
fn previous_random(&self) -> i32;
fn set_previous_random(&mut self, val: i32);
fn next_random<R: StoryRng>(&self, seed: i32) -> i32;
fn random_sequence<R: StoryRng>(&self, seed: i32, count: usize) -> Vec<i32>;
}Expand description
Trait for accessing and mutating story execution state.
This is the interface between the VM and the mutable story state.
World implements it directly, as does the
ContextView routing view.
ObservedContext wraps an implementor and fires WriteObserver
callbacks on mutations. Consumers can also implement this trait
themselves to plug in custom observers (e.g. bevy events) or alternate
storage backends.
This does NOT include Program, resolver, or any immutable data — it’s
purely the mutable state surface.
Required Methods§
fn global(&self, idx: u32) -> &Value
fn set_global(&mut self, idx: u32, value: Value)
fn visit_count(&self, id: DefinitionId) -> u32
fn increment_visit(&mut self, id: DefinitionId)
Sourcefn set_visit_count(&mut self, id: DefinitionId, count: u32)
fn set_visit_count(&mut self, id: DefinitionId, count: u32)
Set a visit count directly, rather than incrementing it. Used by
crate::load_state to reconcile a durable save, whose entries carry
absolute counts rather than deltas.
fn turn_count(&self, id: DefinitionId) -> Option<u32>
fn set_turn_count(&mut self, id: DefinitionId, turn: u32)
fn turn_index(&self) -> u32
fn increment_turn_index(&mut self)
Sourcefn set_turn_index(&mut self, index: u32)
fn set_turn_index(&mut self, index: u32)
Set the turn index directly, rather than incrementing it. Used by
crate::load_state to restore a saved turn index.
fn rng_seed(&self) -> i32
fn set_rng_seed(&mut self, seed: i32)
fn previous_random(&self) -> i32
fn set_previous_random(&mut self, val: i32)
fn next_random<R: StoryRng>(&self, seed: i32) -> i32
fn random_sequence<R: StoryRng>(&self, seed: i32, count: usize) -> Vec<i32>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".