[][src]Struct ichen_openprotocol::StateValues

pub struct StateValues<'a> { /* fields omitted */ }

A data structure containing a snapshot of the current known states of the controller.

Methods

impl<'a> StateValues<'a>[src]

pub fn op_mode(&self) -> OpMode[src]

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());

pub fn job_mode(&self) -> JobMode[src]

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());

pub fn operator_id(&self) -> Option<ID>[src]

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());

pub fn job_card_id(&self) -> Option<&str>[src]

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());

pub fn mold_id(&self) -> Option<&str>[src]

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());

pub fn new(op: OpMode, job: JobMode) -> Self[src]

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());

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>
[src]

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

impl<'a> Clone for StateValues<'a>[src]

impl<'a> Debug for StateValues<'a>[src]

impl<'_> Default for StateValues<'_>[src]

fn default() -> Self[src]

Default value of StateValues.

impl<'de: 'a, 'a> Deserialize<'de> for StateValues<'a>[src]

impl<'a> Eq for StateValues<'a>[src]

impl<'a> Hash for StateValues<'a>[src]

impl<'a> PartialEq<StateValues<'a>> for StateValues<'a>[src]

impl<'a> Serialize for StateValues<'a>[src]

impl<'a> StructuralEq for StateValues<'a>[src]

impl<'a> StructuralPartialEq for StateValues<'a>[src]

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any

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