[−][src]Struct ichen_openprotocol::StateValues
A data structure containing a snapshot of the current known states of the controller.
Fields
op_mode: OpModeCurrent operating mold of the controller.
job_mode: JobModeCurrent job mode of the controller.
operator_id: Option<ID>Unique ID of the current logged-in user (if any) on the controller.
job_card_id: Option<Cow<'a, str>>Current active job ID (if any) on the controller.
mold_id: Option<Cow<'a, str>>Unique ID of the set of mold data currently loaded (if any) on the controller.
Methods
impl<'a> StateValues<'a>[src]
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 new_with_all(
op: OpMode,
job: JobMode,
operator: Option<u32>,
job_card: Option<&'a str>,
mold: Option<&'a str>
) -> Self[src]
op: OpMode,
job: JobMode,
operator: Option<u32>,
job_card: Option<&'a str>,
mold: Option<&'a str>
) -> Self
Create a new StateValues with all fields set.
Panics
Panics if operator is Some(0).
// The following will panic because of `Some(0)` in `operator` let state = StateValues::new_with_all(OpMode::Automatic, JobMode::ID02, Some(0), None, Some("M001"));
Examples
let state = StateValues::new_with_all(OpMode::Automatic, JobMode::ID02, Some(123), None, Some("M001")); assert_eq!(OpMode::Automatic, state.op_mode); assert_eq!(JobMode::ID02, state.job_mode); assert_eq!(Some(ID::from_u32(123)), state.operator_id); assert_eq!(None, state.job_card_id); assert_eq!(r#"Some("M001")"#, format!("{:?}", state.mold_id));
pub fn validate(&self) -> Result<'static, ()>[src]
Validate the data structure.
Errors
Returns Err(OpenProtocolError::EmptyField) if job_card_id or mold_id
is set to an empty string or is all whitespace.
Examples
let state = StateValues::new_with_all(OpMode::Automatic, JobMode::ID02, Some(123), Some(""), None); assert_eq!(r#"Err(EmptyField("job_card_id"))"#, format!("{:?}", state.validate()));
Trait Implementations
impl<'_> Default for StateValues<'_>[src]
impl<'a> PartialEq<StateValues<'a>> for StateValues<'a>[src]
fn eq(&self, other: &StateValues<'a>) -> bool[src]
fn ne(&self, other: &StateValues<'a>) -> bool[src]
impl<'a> Debug for StateValues<'a>[src]
impl<'a> Serialize for StateValues<'a>[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl<'de: 'a, 'a> Deserialize<'de> for StateValues<'a>[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl<'a> Sync for StateValues<'a>
impl<'a> Unpin for StateValues<'a>
impl<'a> Send for StateValues<'a>
impl<'a> UnwindSafe for StateValues<'a>
impl<'a> RefUnwindSafe for StateValues<'a>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>, [src]
T: Deserialize<'de>,