nu_protocol/config/
datetime_format.rs1use super::prelude::*;
2use crate as nu_protocol;
3
4#[derive(Clone, Debug, Default, IntoValue, Serialize, Deserialize)]
5pub struct DatetimeFormatConfig {
6 pub normal: Option<String>,
7 pub table: Option<String>,
8}
9
10impl UpdateFromValue for DatetimeFormatConfig {
11 fn update<'a>(
12 &mut self,
13 value: &'a Value,
14 path: &mut ConfigPath<'a>,
15 errors: &mut ConfigErrors,
16 ) {
17 let Value::Record { val: record, .. } = value else {
18 errors.type_mismatch(path, Type::record(), value);
19 return;
20 };
21
22 for (col, val) in record.iter() {
23 let path = &mut path.push(col);
24 match col.as_str() {
25 "normal" => match val {
26 Value::Nothing { .. } => self.normal = None,
27 Value::String { val, .. } => self.normal = Some(val.clone()),
28 _ => errors.type_mismatch(path, Type::custom("string or nothing"), val),
29 },
30 "table" => match val {
31 Value::Nothing { .. } => self.table = None,
32 Value::String { val, .. } => self.table = Some(val.clone()),
33 _ => errors.type_mismatch(path, Type::custom("string or nothing"), val),
34 },
35 _ => errors.unknown_option(path, val),
36 }
37 }
38 }
39}