asterust_junos/system/
pixel_tracing.rs1use crate::arg_of;
9use asterust::config::ConfigLine;
10
11#[derive(Clone, Debug, PartialEq, Eq)]
13#[non_exhaustive]
14pub struct PixelTracing {
15 pub files: Option<String>,
17 pub level: Option<String>,
19}
20
21pub(super) fn parse_pixel_tracing(tracing: &ConfigLine) -> PixelTracing {
22 PixelTracing {
23 files: arg_of(tracing, "files").map(str::to_string),
24 level: arg_of(tracing, "level").map(str::to_string),
25 }
26}
27
28#[cfg(test)]
29mod tests {
30 use crate::system::system;
31 use asterust::config::juniper;
32
33 #[test]
35 fn extracts_pixel_tracing() {
36 let tracing = system(&juniper::parse_braces(
37 "system {\n pixel-tracing {\n files 50;\n level info;\n }\n}\n",
38 ))
39 .unwrap()
40 .pixel_tracing
41 .unwrap();
42 assert_eq!(tracing.files.as_deref(), Some("50"));
43 assert_eq!(tracing.level.as_deref(), Some("info"));
44 }
45
46 #[test]
47 fn no_pixel_tracing_is_none() {
48 let system = system(&juniper::parse_braces("system {\n host-name pe1;\n}\n")).unwrap();
49 assert!(system.pixel_tracing.is_none());
50 }
51}