Skip to main content

World

Struct World 

Source
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

Source

pub fn new(global: GlobalStore) -> Self

A world over the given global store, with an empty scenario scope.

Source

pub fn get(&self, name: &str) -> Option<&Value>

Read a variable: the scenario scope shadows the global store.

Source

pub fn set(&mut self, name: impl Into<String>, value: Value)

Set a variable in the scenario scope.

Source

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).

Source

pub fn global(&self) -> &GlobalStore

The underlying global store.

Source

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.

Source

pub fn merged(&self) -> BTreeMap<&str, &Value>

The merged view (globals overlaid by scenario values), in key order — the seed set for an engine’s variable bridge.

Trait Implementations§

Source§

impl Debug for World

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for World

Source§

fn default() -> World

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.