Struct dypdl::State

source ·
pub struct State {
    pub signature_variables: SignatureVariables,
    pub resource_variables: ResourceVariables,
}
Expand description

State in DyPDL.

Fields§

§signature_variables: SignatureVariables

Variables other than resource variables

§resource_variables: ResourceVariables

Resource variables

Implementations§

source§

impl State

source

pub fn is_satisfied<U: StateInterface>( &self, state: &U, metadata: &StateMetadata ) -> bool

Returns if the given state is equal to the current state.

§Panics

Panics if the state metadata is wrong.

Trait Implementations§

source§

impl Clone for State

source§

fn clone(&self) -> State

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for State

source§

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

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

impl Default for State

source§

fn default() -> State

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

impl PartialEq for State

source§

fn eq(&self, other: &State) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StateInterface for State

source§

fn get_number_of_set_variables(&self) -> usize

Returns the number of set variables.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1, 2, 3]).unwrap();
model.add_set_variable("variable", object_type, set).unwrap();
let state = model.target.clone();

assert_eq!(state.get_number_of_set_variables(), 1);
source§

fn get_set_variable(&self, i: usize) -> &Set

Returns the value of a set variable.

§Panics

Panics if no variable has the id of i.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let set = model.create_set(object_type, &[0, 1, 2, 3]).unwrap();
let variable = model.add_set_variable("variable", object_type, set.clone()).unwrap();
let state = model.target.clone();

assert_eq!(state.get_set_variable(variable.id()), &set);
source§

fn get_number_of_vector_variables(&self) -> usize

Returns the number of vector variables;

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
model.add_vector_variable("variable", object_type, vec![0, 1, 2, 3]).unwrap();
let state = model.target.clone();

assert_eq!(state.get_number_of_vector_variables(), 1);
source§

fn get_vector_variable(&self, i: usize) -> &Vector

Returns the value of a vector variable.

§Panics

Panics if no variable has the id of i.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let variable = model.add_vector_variable("variable", object_type, vec![0, 1, 2, 3]).unwrap();
let state = model.target.clone();

assert_eq!(state.get_vector_variable(variable.id()), &vec![0, 1, 2, 3]);
source§

fn get_number_of_element_variables(&self) -> usize

Returns the number of vector variables;

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
model.add_element_variable("variable", object_type, 0).unwrap();
let state = model.target.clone();

assert_eq!(state.get_number_of_element_variables(), 1);
source§

fn get_element_variable(&self, i: usize) -> Element

Returns the value of an element variable.

§Panics

Panics if no variable has the id of i.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let variable = model.add_element_variable("variable", object_type, 0).unwrap();
let state = model.target.clone();

assert_eq!(state.get_element_variable(variable.id()), 0);
source§

fn get_number_of_integer_variables(&self) -> usize

Returns the number of integer numeric variables;

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.add_integer_variable("variable", 0).unwrap();
let state = model.target.clone();

assert_eq!(state.get_number_of_integer_variables(), 1);
source§

fn get_integer_variable(&self, i: usize) -> Integer

Returns the value of an integer numeric variable.

§Panics

Panics if no variable has the id of i.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_variable("variable", 0).unwrap();
let state = model.target.clone();

assert_eq!(state.get_integer_variable(variable.id()), 0);
source§

fn get_number_of_continuous_variables(&self) -> usize

Returns the number of continuous numeric variables;

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.add_continuous_variable("variable", 0.5).unwrap();
let state = model.target.clone();

assert_eq!(state.get_number_of_continuous_variables(), 1);
source§

fn get_continuous_variable(&self, i: usize) -> Continuous

Returns the value of a continuous numeric variable.

§Panics

Panics if no variable has the id of i.

§Examples
use approx::assert_relative_eq;
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_continuous_variable("variable", 0.5).unwrap();
let state = model.target.clone();

assert_relative_eq!(state.get_continuous_variable(variable.id()), 0.5);
source§

fn get_number_of_element_resource_variables(&self) -> usize

Returns the number of element resource variables;

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
model.add_element_resource_variable("variable", object_type, false, 0).unwrap();
let state = model.target.clone();

assert_eq!(state.get_number_of_element_resource_variables(), 1);
source§

fn get_element_resource_variable(&self, i: usize) -> Element

Returns the value of an element resource variable.

§Panics

Panics if no variable has the id of i.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let object_type = model.add_object_type("object", 4).unwrap();
let variable = model.add_element_resource_variable("variable", object_type, false, 0).unwrap();
let state = model.target.clone();

assert_eq!(state.get_element_resource_variable(variable.id()), 0);
source§

fn get_number_of_integer_resource_variables(&self) -> usize

Returns the number of integer resource variables;

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.add_integer_resource_variable("variable", false, 0).unwrap();
let state = model.target.clone();

assert_eq!(state.get_number_of_integer_resource_variables(), 1);
source§

fn get_integer_resource_variable(&self, i: usize) -> Integer

Returns the value of an integer resource variable.

§Panics

Panics if no variable has the id of i.

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_integer_resource_variable("variable", false, 0).unwrap();
let state = model.target.clone();

assert_eq!(state.get_integer_resource_variable(variable.id()), 0);
source§

fn get_number_of_continuous_resource_variables(&self) -> usize

Returns the number of continuous resource variables;

§Examples
use dypdl::prelude::*;

let mut model = Model::default();
model.add_continuous_resource_variable("variable", false, 0.5).unwrap();
let state = model.target.clone();

assert_eq!(state.get_number_of_continuous_resource_variables(), 1);
source§

fn get_continuous_resource_variable(&self, i: usize) -> Continuous

Returns the value of a continuous resource variable.

§Panics

Panics if no variable has the id of i.

§Examples
use approx::assert_relative_eq;
use dypdl::prelude::*;

let mut model = Model::default();
let variable = model.add_continuous_resource_variable("variable", false, 0.5).unwrap();
let state = model.target.clone();

assert_relative_eq!(state.get_continuous_resource_variable(variable.id()), 0.5);
source§

fn apply_effect<T: From<State>>( &self, effect: &Effect, registry: &TableRegistry ) -> T

Returns the transitioned state by the effect. Read more
source§

impl StructuralPartialEq for State

Auto Trait Implementations§

§

impl RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnwindSafe for State

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.