Struct sim::simulator::web::Simulation

source ·
pub struct Simulation { /* private fields */ }
Expand description

The web Simulation provides JS/WASM-compatible interfaces to the core Simulation struct. For additional insight on these methods, refer to the associated core Simulation methods. Errors are unwrapped, instead of returned, in the web Simulation methods.

Implementations§

source§

impl Simulation

source

pub fn post_json(models: &str, connectors: &str) -> Self

A JS/WASM interface for Simulation.post, which uses JSON representations of the simulation models and connectors.

source

pub fn put_json(&mut self, models: &str, connectors: &str)

A JS/WASM interface for Simulation.put, which uses JSON representations of the simulation models and connectors.

source

pub fn get_json(&self) -> String

Get a JSON representation of the full Simulation configuration.

source

pub fn post_yaml(models: &str, connectors: &str) -> Simulation

A JS/WASM interface for Simulation.post, which uses YAML representations of the simulation models and connectors.

source

pub fn put_yaml(&mut self, models: &str, connectors: &str)

A JS/WASM interface for Simulation.put, which uses YAML representations of the simulation models and connectors.

source

pub fn get_yaml(&self) -> String

Get a YAML representation of the full Simulation configuration.

source

pub fn get_messages_js(&self) -> Array

A JS/WASM interface for Simulation.get_messages, which converts the messages to a JavaScript Array.

source

pub fn get_messages_json(&self) -> String

A JS/WASM interface for Simulation.get_messages, which converts the messages to a JSON string.

source

pub fn get_messages_yaml(&self) -> String

A JS/WASM interface for Simulation.get_messages, which converts the messages to a YAML string.

source

pub fn get_global_time(&self) -> f64

An interface to Simulation.get_global_time.

source

pub fn get_status(&self, model_id: &str) -> String

An interface to Simulation.get_status.

source

pub fn get_records_json(&self, model_id: &str) -> String

A JS/WASM interface for Simulation.records, which converts the records to a JSON string.

source

pub fn get_records_yaml(&self, model_id: &str) -> String

A JS/WASM interface for Simulation.records, which converts the records to a YAML string.

source

pub fn reset(&mut self)

An interface to Simulation.reset.

source

pub fn reset_messages(&mut self)

An interface to Simulation.reset_messages.

source

pub fn reset_global_time(&mut self)

An interface to Simulation.reset_global_time

source

pub fn inject_input_json(&mut self, message: &str)

A JS/WASM interface for Simulation.inject_input, which uses a JSON representation of the injected messages.

source

pub fn inject_input_yaml(&mut self, message: &str)

A JS/WASM interface for Simulation.inject_input, which uses a YAML representation of the injected messages.

source

pub fn step_js(&mut self) -> Array

A JS/WASM interface for Simulation.step, which converts the returned messages to a JavaScript Array.

source

pub fn step_json(&mut self) -> String

A JS/WASM interface for Simulation.step, which converts the returned messages to a JSON string.

source

pub fn step_yaml(&mut self) -> String

A JS/WASM interface for Simulation.step, which converts the returned messages to a YAML string.

source

pub fn step_until_js(&mut self, until: f64) -> Array

A JS/WASM interface for Simulation.step_until, which converts the returned messages to a JavaScript Array.

source

pub fn step_until_json(&mut self, until: f64) -> String

A JS/WASM interface for Simulation.step_until, which converts the returned messages to a JSON string.

source

pub fn step_until_yaml(&mut self, until: f64) -> String

A JS/WASM interface for Simulation.step_until, which converts the returned messages to a YAML string.

source

pub fn step_n_js(&mut self, n: usize) -> Array

A JS/WASM interface for Simulation.step_n, which converts the returned messages to a JavaScript Array.

source

pub fn step_n_json(&mut self, n: usize) -> String

A JS/WASM interface for Simulation.step_n, which converts the returned messages to a JSON string.

source

pub fn step_n_yaml(&mut self, n: usize) -> String

A JS/WASM interface for Simulation.step_n, which converts the returned messages to a YAML string.

Trait Implementations§

source§

impl Default for Simulation

source§

fn default() -> Simulation

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

impl<'de> Deserialize<'de> for Simulation

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Simulation> for JsValue

source§

fn from(value: Simulation) -> Self

Converts to this type from the input type.
source§

impl FromWasmAbi for Simulation

§

type Abi = u32

The wasm ABI type that this converts from when coming back out from the ABI boundary.
source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
source§

impl IntoWasmAbi for Simulation

§

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI boundary.
source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
source§

impl LongRefFromWasmAbi for Simulation

§

type Abi = u32

Same as RefFromWasmAbi::Abi
§

type Anchor = Ref<'static, Simulation>

Same as RefFromWasmAbi::Anchor
source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
source§

impl OptionFromWasmAbi for Simulation

source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
source§

impl OptionIntoWasmAbi for Simulation

source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
source§

impl RefFromWasmAbi for Simulation

§

type Abi = u32

The wasm ABI type references to Self are recovered from.
§

type Anchor = Ref<'static, Simulation>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
source§

impl RefMutFromWasmAbi for Simulation

§

type Abi = u32

Same as RefFromWasmAbi::Abi
§

type Anchor = RefMut<'static, Simulation>

Same as RefFromWasmAbi::Anchor
source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
source§

impl Serialize for Simulation

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFromJsValue for Simulation

§

type Error = JsValue

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

fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl VectorFromWasmAbi for Simulation

§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Simulation]>

source§

impl VectorIntoWasmAbi for Simulation

§

type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi

source§

fn vector_into_abi(vector: Box<[Simulation]>) -> Self::Abi

source§

impl WasmDescribe for Simulation

source§

impl WasmDescribeVector for Simulation

Auto Trait Implementations§

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> ReturnWasmAbi for T
where T: IntoWasmAbi,

§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
source§

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

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,