pub struct World { /* private fields */ }Expand description
One typed variable scope per scenario, layered over the persistent global store.
Reads resolve scenario-first (scenario values shadow globals); saveAs: global
writes through to the store.
Implementations§
Source§impl World
impl World
Sourcepub fn new(global: GlobalStore) -> Self
pub fn new(global: GlobalStore) -> Self
A world over the given global store, with an empty scenario scope.
Sourcepub fn get(&self, name: &str) -> Option<&Value>
pub fn get(&self, name: &str) -> Option<&Value>
Read a variable: the scenario scope shadows the global store.
Sourcepub fn set(&mut self, name: impl Into<String>, value: Value)
pub fn set(&mut self, name: impl Into<String>, value: Value)
Set a variable in the scenario scope.
Sourcepub fn set_global(&mut self, name: impl Into<String>, value: Value)
pub fn set_global(&mut self, name: impl Into<String>, value: Value)
Promote a value into the persistent global store (saveAs: global).
The key joins the scenario’s write set (see World::promotions).
Sourcepub fn global(&self) -> &GlobalStore
pub fn global(&self) -> &GlobalStore
The underlying global store.
Sourcepub fn promotions(&self) -> impl Iterator<Item = (&str, &Value)>
pub fn promotions(&self) -> impl Iterator<Item = (&str, &Value)>
The scenario’s promotions — only the keys actually written via
World::set_global, with their current values. This is what merges
back into the shared store; the untouched snapshot remainder must not.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for World
impl RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl UnsafeUnpin for World
impl UnwindSafe for World
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more