src/config/network.rs: use a simple String for comments
This commit is contained in:
@ -126,12 +126,12 @@ pub enum DeletableProperty {
|
||||
optional: true,
|
||||
},
|
||||
comments_v4: {
|
||||
description: "Comments (inet)",
|
||||
description: "Comments (inet, may span multiple lines)",
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
comments_v6: {
|
||||
description: "Comments (inet6)",
|
||||
description: "Comments (inet5, may span multiple lines)",
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
@ -221,8 +221,8 @@ pub fn update_interface(
|
||||
DeletableProperty::gateway_v6 => { interface.gateway_v6 = None; },
|
||||
DeletableProperty::method_v4 => { interface.method_v4 = None; },
|
||||
DeletableProperty::method_v6 => { interface.method_v6 = None; },
|
||||
DeletableProperty::comments_v4 => { interface.comments_v4 = Vec::new(); },
|
||||
DeletableProperty::comments_v6 => { interface.comments_v6 = Vec::new(); },
|
||||
DeletableProperty::comments_v4 => { interface.comments_v4 = None; },
|
||||
DeletableProperty::comments_v6 => { interface.comments_v6 = None; },
|
||||
DeletableProperty::mtu => { interface.mtu = None; },
|
||||
DeletableProperty::auto => { interface.auto = false; },
|
||||
DeletableProperty::bridge_ports => { interface.set_bridge_ports(Vec::new())?; }
|
||||
@ -266,13 +266,8 @@ pub fn update_interface(
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(comments) = comments_v4 {
|
||||
interface.comments_v4 = comments.lines().map(String::from).collect();
|
||||
}
|
||||
|
||||
if let Some(comments) = comments_v6 {
|
||||
interface.comments_v6 = comments.lines().map(String::from).collect();
|
||||
}
|
||||
if comments_v4.is_some() { interface.comments_v4 = comments_v4; }
|
||||
if comments_v6.is_some() { interface.comments_v6 = comments_v6; }
|
||||
|
||||
network::save_config(&config)?;
|
||||
|
||||
|
@ -587,20 +587,14 @@ pub const NETWORK_INTERFACE_LIST_SCHEMA: Schema = ArraySchema::new(
|
||||
},
|
||||
},
|
||||
comments_v4: {
|
||||
description: "Comments (inet)",
|
||||
type: Array,
|
||||
items: {
|
||||
description: "Comment line.",
|
||||
type: String,
|
||||
},
|
||||
description: "Comments (inet, may span multiple lines)",
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
comments_v6: {
|
||||
description: "Comments (inet6)",
|
||||
type: Array,
|
||||
items: {
|
||||
description: "Comment line.",
|
||||
type: String,
|
||||
},
|
||||
description: "Comments (inet6, may span multiple lines)",
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
bridge_ports: {
|
||||
schema: NETWORK_INTERFACE_LIST_SCHEMA,
|
||||
@ -645,10 +639,10 @@ pub struct Interface {
|
||||
#[serde(skip_serializing_if="Vec::is_empty")]
|
||||
pub options_v6: Vec<String>,
|
||||
|
||||
#[serde(skip_serializing_if="Vec::is_empty")]
|
||||
pub comments_v4: Vec<String>,
|
||||
#[serde(skip_serializing_if="Vec::is_empty")]
|
||||
pub comments_v6: Vec<String>,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub comments_v4: Option<String>,
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub comments_v6: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
/// Maximum Transmission Unit
|
||||
|
Reference in New Issue
Block a user