pub struct Operator<'a> { /* private fields */ }
Expand description
A data structure containing information on a single user on the system.
Implementations§
Source§impl<'a> Operator<'a>
impl<'a> Operator<'a>
Sourcepub fn id(&self) -> ID
pub fn id(&self) -> ID
Get the operator ID.
§Examples
let opr = Operator::new(ID::from_u32(12345));
assert_eq!(12345, opr.id());
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
§Examples
let opr = Operator::try_new_with_name(ID::from_u32(12345), "John")?;
assert_eq!(Some("John"), opr.name());
Sourcepub fn new(id: ID) -> Self
pub fn new(id: ID) -> Self
Create an Operator
with just an ID and no name.
§Examples
let opr = Operator::new(ID::from_u32(12345));
assert_eq!(12345, opr.id());
assert_eq!(None, opr.name());
Sourcepub fn try_new_with_name(id: ID, name: &'a str) -> Result<Self, String>
pub fn try_new_with_name(id: ID, name: &'a str) -> Result<Self, String>
Create an Operator
with ID and name.
§Errors
Returns Err(
[OpenProtocolError::EmptyField
])
if the operator_name
field is
set to an empty string or is all whitespace.
§Error Examples
let result = Operator::try_new_with_name(ID::from_u32(12345), "");
assert_eq!(Err("invalid value: a non-empty, non-whitespace string required for operator name".into()), result);
§Examples
let opr = Operator::try_new_with_name(ID::from_u32(12345), "John")?;
assert_eq!(12345, opr.id());
assert_eq!(Some("John"), opr.name());
Trait Implementations§
Source§impl<'de: 'a, 'a> Deserialize<'de> for Operator<'a>
impl<'de: 'a, 'a> Deserialize<'de> for Operator<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<'a> Eq for Operator<'a>
impl<'a> StructuralPartialEq for Operator<'a>
Auto Trait Implementations§
impl<'a> Freeze for Operator<'a>
impl<'a> RefUnwindSafe for Operator<'a>
impl<'a> Send for Operator<'a>
impl<'a> Sync for Operator<'a>
impl<'a> Unpin for Operator<'a>
impl<'a> UnwindSafe for Operator<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.