[−][src]Struct ichen_openprotocol::JobCard
A data structure containing information on a production job (i.e. a job card).
Fields
job_card_id: Cow<'a, str>
Unique job ID, which must not be empty or all white-spaces.
mold_id: Cow<'a, str>
ID of the set of mold data to load for this job.
progress: u32
Current production progress, which must not be larger than total
.
total: u32
Total production count ordered.
Methods
impl<'a> JobCard<'a>
[src]
pub fn new(id: &'a str, mold: &'a str, progress: u32, total: u32) -> Self
[src]
Create a new JobCard
with the specified field values.
Examples
let jobs = vec![ JobCard::new("J001".into(), "Mold#001".into(), 0, 10000), JobCard::new("J002".into(), "Mold#002".into(), 1000, 5000), JobCard::new("J003".into(), "Mold#003".into(), 42, 1000), JobCard::new("J004".into(), "Mold#004".into(), 0, 0), ]; assert_eq!(4, jobs.len()); assert_eq!("J002", jobs[1].job_card_id); assert_eq!(1000, jobs[2].total);
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.
Returns Err(
OpenProtocolError::ConstraintViolated
)
if progress
is larger
than total
.
Examples
let job1 = JobCard::new("".into(), "M1".into(), 0, 10000); let job2 = JobCard::new("J2".into(), " ".into(), 0, 10000); let job3 = JobCard::new("J3".into(), "M3".into(), 50000, 10000); assert_eq!(r#"Err(EmptyField("job_card_id"))"#, format!("{:?}", job1.validate())); assert_eq!(r#"Err(EmptyField("mold_id"))"#, format!("{:?}", job2.validate())); assert_eq!( r#"Err(ConstraintViolated("job-card progress (50000) must not be larger than the total production count (10000)"))"#, format!("{:?}", job3.validate()) );
Trait Implementations
impl<'a> Clone for JobCard<'a>
[src]
fn clone(&self) -> JobCard<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> PartialEq<JobCard<'a>> for JobCard<'a>
[src]
impl<'a> Debug for JobCard<'a>
[src]
impl<'a> Serialize for JobCard<'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 JobCard<'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 JobCard<'a>
impl<'a> Unpin for JobCard<'a>
impl<'a> Send for JobCard<'a>
impl<'a> UnwindSafe for JobCard<'a>
impl<'a> RefUnwindSafe for JobCard<'a>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,