pub fn match_client_identity<'a>(
identities: &'a [ClientIdentity],
reference: &str,
) -> Result<Option<&'a ClientIdentity>>Expand description
The identity of identities that reference names: its uuid, its identify value,
or its name (trimmed, case does not matter), in that order. Ok(None) if none
matches.
§Errors
Error::InvalidInput if the name matches several identities (names are not unique);
the message lists their identify values.
§Examples
use dinio_sdk::models::ClientIdentity;
use dinio_sdk::ops::match_client_identity;
let all = [
identity(1, "k3x7q2mzr5tvb4wa", Some("Phone")),
identity(2, "p2d6hn4cw7yzq3sl", Some("laptop")),
identity(3, "a5b6c7d2e3f4g5h6", Some("laptop")),
];
let phone = match_client_identity(&all, "phone").unwrap().unwrap();
assert_eq!(phone.identify, "k3x7q2mzr5tvb4wa");
assert!(match_client_identity(&all, "p2d6hn4cw7yzq3sl").unwrap().is_some());
assert!(match_client_identity(&all, "laptop").is_err());
assert!(match_client_identity(&all, "tablet").unwrap().is_none());