Constructor from zbus object for Settings

This commit is contained in:
Lucy 2022-01-26 13:32:13 -05:00
parent ce01d9befd
commit 8df68611fe
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1

View file

@ -74,6 +74,23 @@ pub struct Settings {
}
impl Settings {
pub fn new(
mut src: std::collections::HashMap<
String,
std::collections::HashMap<String, zbus::zvariant::OwnedValue>,
>,
) -> Self {
Self {
connection: src.remove("connection").map(ConnectionSettings::new),
ethernet: src.remove("802-3-ethernet").map(EthernetSettings::new),
wifi: src.remove("802-11-wireless").map(WifiSettings::new),
bluetooth: src.remove("bluetooth").map(BluetoothSettings::new),
ipv4: src.remove("ipv4").map(Ipv4Settings::new),
ipv6: src.remove("ipv6").map(Ipv6Settings::new),
proxy: src.remove("proxy").map(WwwProxySettings::new),
}
}
pub fn build(
&self,
) -> std::collections::HashMap<