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