[][src]Struct ichen_openprotocol::Operator

pub struct Operator<'a> {
    pub operator_id: ID,
    pub operator_name: Option<&'a str>,
}

A data structure containing information on a single user on the system.

Fields

operator_id: ID

Unique user ID, which cannot be zero.

operator_name: Option<&'a str>

Name of the user.

Methods

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

pub fn new(id: ID) -> Self[src]

Create an Operator with just an ID and no name.

Examples

let op = Operator::new(ID::from(12345));
assert_eq!(12345, u32::from(op.operator_id));
assert_eq!(None, op.operator_name);

pub fn new_with_name(id: ID, name: &'a str) -> Self[src]

Create an Operator with ID and name.

Examples

let op = Operator::new_with_name(ID::from(12345), "John");
assert_eq!(12345, u32::from(op.operator_id));
assert_eq!(Some("John"), op.operator_name);

pub fn validate(&self) -> Result<'static, ()>[src]

Validate the data structure.

Errors

Returns Err(OpenProtocolError::EmptyField) if the operator_name field is set to an empty string or is all whitespace.

Examples

let op = Operator::new_with_name(ID::from(12345), "John");
assert_eq!(r#"Err(EmptyField("operator_name"))"#, format!("{:?}", op.validate()));

Trait Implementations

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

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

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

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

Auto Trait Implementations

impl<'a> Sync for Operator<'a>

impl<'a> Send for Operator<'a>

impl<'a> Unpin for Operator<'a>

impl<'a> RefUnwindSafe for Operator<'a>

impl<'a> UnwindSafe for Operator<'a>

Blanket Implementations

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

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

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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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

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