pub struct StateValues<'a> { /* private fields */ }
Expand description
A data structure containing a snapshot of the current known states of the controller.
Implementations§
Source§impl<'a> StateValues<'a>
impl<'a> StateValues<'a>
Sourcepub fn op_mode(&self) -> OpMode
pub fn op_mode(&self) -> OpMode
Get the op-mode.
§Examples
let state = StateValues::try_new_with_all(
OpMode::Automatic,
JobMode::ID02,
Some(ID::from_u32(123)),
None,
Some("M001")
)?;
assert_eq!(OpMode::Automatic, state.op_mode());
Sourcepub fn job_mode(&self) -> JobMode
pub fn job_mode(&self) -> JobMode
Get the job mode.
§Examples
let state = StateValues::try_new_with_all(
OpMode::Automatic,
JobMode::ID02,
Some(ID::from_u32(123)),
None,
Some("M001")
)?;
assert_eq!(JobMode::ID02, state.job_mode());
Sourcepub fn operator_id(&self) -> Option<ID>
pub fn operator_id(&self) -> Option<ID>
Get the operator ID, if any.
§Examples
let state = StateValues::try_new_with_all(
OpMode::Automatic,
JobMode::ID02,
Some(ID::from_u32(123)),
None,
Some("M001")
)?;
assert_eq!(123, state.operator_id().unwrap());
Sourcepub fn job_card_id(&self) -> Option<&str>
pub fn job_card_id(&self) -> Option<&str>
Get the job card ID, if any.
§Examples
let state = StateValues::try_new_with_all(
OpMode::Automatic,
JobMode::ID02,
Some(ID::from_u32(123)),
Some("JC001"),
None
)?;
assert_eq!(Some("JC001"), state.job_card_id());
Sourcepub fn mold_id(&self) -> Option<&str>
pub fn mold_id(&self) -> Option<&str>
Get the mold ID, if any.
§Examples
let state = StateValues::try_new_with_all(
OpMode::Automatic,
JobMode::ID02,
Some(ID::from_u32(123)),
None,
Some("M001")
)?;
assert_eq!(Some("M001"), state.mold_id());
Sourcepub fn new(op: OpMode, job: JobMode) -> Self
pub fn new(op: OpMode, job: JobMode) -> Self
Create a new StateValues
wth no operator ID, job card ID and mold ID.
§Examples
let state = StateValues::new(OpMode::Automatic, JobMode::ID02);
assert_eq!(OpMode::Automatic, state.op_mode());
assert_eq!(JobMode::ID02, state.job_mode());
assert_eq!(None, state.operator_id());
assert_eq!(None, state.job_card_id());
assert_eq!(None, state.mold_id());
Sourcepub fn try_new_with_all(
op: OpMode,
job: JobMode,
operator_id: Option<ID>,
job_card_id: Option<&'a str>,
mold_id: Option<&'a str>,
) -> Result<Self, String>
pub fn try_new_with_all( op: OpMode, job: JobMode, operator_id: Option<ID>, job_card_id: Option<&'a str>, mold_id: Option<&'a str>, ) -> Result<Self, String>
Create a new StateValues
with all fields set.
§Errors
Returns Err(String)
if job_card_id
or mold_id
is set to an empty string
or is all whitespace.
§Error Examples
let sv = StateValues::try_new_with_all(
OpMode::Automatic,
JobMode::ID02,
Some(ID::from_u32(123)),
Some(""), // <-- Notice empty string for job_Card_id which is not allowed
None
);
assert_eq!(Err("invalid value: a non-empty, non-whitespace string required for job card ID".into()), sv);
§Examples
let state = StateValues::try_new_with_all(
OpMode::Automatic,
JobMode::ID02,
Some(ID::from_u32(123)),
None,
Some("M001")
)?;
assert_eq!(OpMode::Automatic, state.op_mode());
assert_eq!(JobMode::ID02, state.job_mode());
assert_eq!(123, state.operator_id().unwrap());
assert_eq!(None, state.job_card_id());
assert_eq!(Some("M001"), state.mold_id());
Trait Implementations§
Source§impl<'a> Clone for StateValues<'a>
impl<'a> Clone for StateValues<'a>
Source§fn clone(&self) -> StateValues<'a>
fn clone(&self) -> StateValues<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for StateValues<'a>
impl<'a> Debug for StateValues<'a>
Source§impl<'de: 'a, 'a> Deserialize<'de> for StateValues<'a>
impl<'de: 'a, 'a> Deserialize<'de> for StateValues<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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<'a> Hash for StateValues<'a>
impl<'a> Hash for StateValues<'a>
Source§impl<'a> PartialEq for StateValues<'a>
impl<'a> PartialEq for StateValues<'a>
Source§impl<'a> Serialize for StateValues<'a>
impl<'a> Serialize for StateValues<'a>
impl<'a> Eq for StateValues<'a>
impl<'a> StructuralPartialEq for StateValues<'a>
Auto Trait Implementations§
impl<'a> Freeze for StateValues<'a>
impl<'a> RefUnwindSafe for StateValues<'a>
impl<'a> Send for StateValues<'a>
impl<'a> Sync for StateValues<'a>
impl<'a> Unpin for StateValues<'a>
impl<'a> UnwindSafe for StateValues<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.