nethsm/base/
utils.rs

1//! Utility functionality shared across the [`NetHsm`] implementation.
2
3#[cfg(doc)]
4use crate::NetHsm;
5use crate::UserId;
6
7/// Creates a string for when there is a user or there is no user.
8///
9/// Creates the string `the user <user>` if `user` is [`Some`].
10/// Creates the string `no user` if `user` is [`None`].
11pub(crate) fn user_or_no_user_string(user: Option<&UserId>) -> String {
12    if let Some(current_credentials) = user {
13        format!("the user {current_credentials}")
14    } else {
15        "no user".to_string()
16    }
17}