asterust_junos/system/login/
user.rs1use crate::system::authentication_methods;
9use crate::{arg_of, child_block};
10use asterust::config::ConfigLine;
11
12#[derive(Clone, Debug, PartialEq, Eq)]
15#[non_exhaustive]
16pub struct LoginUser {
17 pub name: String,
18 pub class: Option<String>,
19 pub uid: Option<String>,
20 pub full_name: Option<String>,
21 pub authentication_methods: Vec<String>,
23}
24
25pub(super) fn parse_user(name: &str, user: &ConfigLine) -> LoginUser {
26 LoginUser {
27 name: name.to_string(),
28 class: arg_of(user, "class").map(str::to_string),
29 uid: arg_of(user, "uid").map(str::to_string),
30 full_name: arg_of(user, "full-name").map(str::to_string),
31 authentication_methods: child_block(user, "authentication")
32 .map(authentication_methods)
33 .unwrap_or_default(),
34 }
35}