nu_protocol/config/
clip.rs1use super::prelude::*;
2use crate as nu_protocol;
3
4#[derive(Clone, Debug, IntoValue, Serialize, Deserialize)]
5pub struct ClipConfig {
6 pub resident_mode: bool,
7 pub default_raw: bool,
8}
9
10#[allow(clippy::derivable_impls)]
11impl Default for ClipConfig {
12 fn default() -> Self {
13 Self {
14 resident_mode: cfg!(target_os = "linux"),
15 default_raw: false,
16 }
17 }
18}
19
20impl UpdateFromValue for ClipConfig {
21 fn update<'a>(
22 &mut self,
23 value: &'a Value,
24 path: &mut ConfigPath<'a>,
25 errors: &mut ConfigErrors,
26 ) {
27 let Value::Record { val: record, .. } = value else {
28 errors.type_mismatch(path, Type::record(), value);
29 return;
30 };
31
32 for (col, val) in record.iter() {
33 let path = &mut path.push(col);
34 match col.as_str() {
35 "resident_mode" => self.resident_mode.update(val, path, errors),
36 "default_raw" => self.default_raw.update(val, path, errors),
37 _ => errors.unknown_option(path, val),
38 }
39 }
40 }
41}