pub struct NetHsmMetricsUsers {
metrics_user: SystemWideUserId,
operator_users: Vec<UserId>,
}
Expand description
A set of users with unique [UserId
]s, used for metrics retrieval
This struct tracks a user that is intended for the use in the
[Metrics
][nethsm::UserRole::Metrics
] role and a list of users, that are intended to be used
in the [Operator
][nethsm::UserRole::Operator
] role.
Fields§
§metrics_user: SystemWideUserId
§operator_users: Vec<UserId>
Implementations§
Source§impl NetHsmMetricsUsers
impl NetHsmMetricsUsers
Sourcepub fn new(
metrics_user: SystemWideUserId,
operator_users: Vec<UserId>,
) -> Result<Self, Error>
pub fn new( metrics_user: SystemWideUserId, operator_users: Vec<UserId>, ) -> Result<Self, Error>
Creates a new NetHsmMetricsUsers
§Error
Returns an error, if the provided [UserId
] of the metrics_user
is duplicated in the
provided operator_users
.
§Examples
use nethsm_config::NetHsmMetricsUsers;
NetHsmMetricsUsers::new(
"metrics1".parse()?,
vec!["user1".parse()?, "user2".parse()?],
)?;
// this fails because there are duplicate UserIds
assert!(NetHsmMetricsUsers::new(
"metrics1".parse()?,
vec!["metrics1".parse()?, "user2".parse()?,],
)
.is_err());
Sourcepub fn get_users(&self) -> Vec<UserId>
pub fn get_users(&self) -> Vec<UserId>
Returns all tracked [UserId
]s of the NetHsmMetricsUsers
§Examples
use nethsm::UserId;
use nethsm_config::NetHsmMetricsUsers;
let nethsm_metrics_users = NetHsmMetricsUsers::new(
"metrics1".parse()?,
vec!["user1".parse()?, "user2".parse()?],
)?;
assert_eq!(
nethsm_metrics_users.get_users(),
vec![
UserId::new("metrics1".to_string())?,
UserId::new("user1".to_string())?,
UserId::new("user2".to_string())?
]
);
Trait Implementations§
Source§impl Clone for NetHsmMetricsUsers
impl Clone for NetHsmMetricsUsers
Source§fn clone(&self) -> NetHsmMetricsUsers
fn clone(&self) -> NetHsmMetricsUsers
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for NetHsmMetricsUsers
impl Debug for NetHsmMetricsUsers
Source§impl<'de> Deserialize<'de> for NetHsmMetricsUsers
impl<'de> Deserialize<'de> for NetHsmMetricsUsers
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
Source§impl Hash for NetHsmMetricsUsers
impl Hash for NetHsmMetricsUsers
Source§impl PartialEq for NetHsmMetricsUsers
impl PartialEq for NetHsmMetricsUsers
Source§impl Serialize for NetHsmMetricsUsers
impl Serialize for NetHsmMetricsUsers
impl Eq for NetHsmMetricsUsers
impl StructuralPartialEq for NetHsmMetricsUsers
Auto Trait Implementations§
impl Freeze for NetHsmMetricsUsers
impl RefUnwindSafe for NetHsmMetricsUsers
impl Send for NetHsmMetricsUsers
impl Sync for NetHsmMetricsUsers
impl Unpin for NetHsmMetricsUsers
impl UnwindSafe for NetHsmMetricsUsers
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.