[][src]Struct ichen_openprotocol::JobCard

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

A data structure containing information on a production job (i.e. a job card).

Methods

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

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

Get the job ID.

Examples

let jc = JobCard::try_new("J001", "Mold#001", 100, 1000)?;
assert_eq!("J001", jc.job_card_id());

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

Get the mold ID.

Examples

let jc = JobCard::try_new("J001", "Mold#001", 100, 1000)?;
assert_eq!("Mold#001", jc.mold_id());

pub fn progress(&self) -> u32[src]

Get the production progress.

Examples

let jc = JobCard::try_new("J001", "Mold#001", 100, 1000)?;
assert_eq!(100, jc.progress());

pub fn total(&self) -> u32[src]

Get the maximum production order.

Examples

let jc = JobCard::try_new("J001", "Mold#001", 100, 1000)?;
assert_eq!(1000, jc.total());

pub fn try_new(
    id: &'a str,
    mold: &'a str,
    progress: u32,
    total: u32
) -> Result<Self, String>
[src]

Create a new JobCard with the specified field values.

Errors

Returns Err(String) is there is an error in the parameters.

Error Examples

assert_eq!(
    Err("invalid value: a non-empty, non-whitespace string required for job card ID".into()),
    JobCard::try_new("", "Mold#001", 0, 10000)
);

assert_eq!(
    Err("invalid value: a non-empty, non-whitespace string required for mold ID".into()),
    JobCard::try_new("J001", "   ", 0, 10000)
);

assert_eq!(
    Err("progress cannot be larger than total".into()),
    JobCard::try_new("J001", "Mold#001", 1000, 100)
);

Examples

let jobs = vec![
    JobCard::try_new("J001", "Mold#001", 0, 10000)?,
    JobCard::try_new("J002", "Mold#002", 1000, 5000)?,
    JobCard::try_new("J003", "Mold#003", 42, 1000)?,
    JobCard::try_new("J004", "Mold#004", 0, 0)?,
];

assert_eq!(4, jobs.len());
assert_eq!("J002", jobs[1].job_card_id());
assert_eq!(1000, jobs[2].total());

Trait Implementations

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

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

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

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

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

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

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

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

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

Auto Trait Implementations

impl<'a> RefUnwindSafe for JobCard<'a>

impl<'a> Send for JobCard<'a>

impl<'a> Sync for JobCard<'a>

impl<'a> Unpin for JobCard<'a>

impl<'a> UnwindSafe for JobCard<'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>,