diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e2b0aab33e..ef744d5d23 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -32,6 +32,9 @@ dependencies = [ "agama-network", "anyhow", "async-std", + "log", + "simplelog", + "systemd-journal-logger", "zbus", "zbus_macros", ] @@ -56,6 +59,7 @@ dependencies = [ "futures", "futures-util", "jsonschema", + "log", "serde", "serde_json", "tempfile", @@ -638,6 +642,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", + "subtle", ] [[package]] @@ -903,6 +908,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + [[package]] name = "idna" version = "0.3.0" @@ -1039,6 +1053,24 @@ version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +[[package]] +name = "libsystemd" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b9597a67aa1c81a6624603e6bd0bcefb9e0f94c9c54970ec53771082104b4e" +dependencies = [ + "hmac", + "libc", + "log", + "nix", + "nom", + "once_cell", + "serde", + "sha2", + "thiserror", + "uuid", +] + [[package]] name = "libz-sys" version = "1.1.9" @@ -1212,6 +1244,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + [[package]] name = "number_prefix" version = "0.4.0" @@ -1593,6 +1634,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "signal-hook" version = "0.3.15" @@ -1612,6 +1664,17 @@ dependencies = [ "libc", ] +[[package]] +name = "simplelog" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acee08041c5de3d5048c8b3f6f13fafb3026b24ba43c6a695a0c76179b844369" +dependencies = [ + "log", + "termcolor", + "time", +] + [[package]] name = "siphasher" version = "0.3.10" @@ -1655,6 +1718,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "1.0.109" @@ -1677,6 +1746,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "systemd-journal-logger" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "356b5cb52ce54916cbfaee19b07d305c7ea8ce5435a088c58743d4a0211f3eff" +dependencies = [ + "libsystemd", + "log", +] + [[package]] name = "tempfile" version = "3.5.0" @@ -1690,6 +1769,15 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.40" @@ -1716,6 +1804,9 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ + "itoa", + "libc", + "num_threads", "serde", "time-core", "time-macros", @@ -1879,6 +1970,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" dependencies = [ "getrandom", + "serde", ] [[package]] @@ -2007,6 +2099,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/rust/agama-cli/src/config.rs b/rust/agama-cli/src/config.rs index ebcb52c6db..dbeab414f0 100644 --- a/rust/agama-cli/src/config.rs +++ b/rust/agama-cli/src/config.rs @@ -1,11 +1,11 @@ use crate::error::CliError; use crate::printers::{print, Format}; -use clap::Subcommand; -use convert_case::{Case, Casing}; use agama_lib::connection; use agama_lib::install_settings::{InstallSettings, Scope}; use agama_lib::settings::{SettingObject, SettingValue, Settings}; use agama_lib::Store as SettingsStore; +use clap::Subcommand; +use convert_case::{Case, Casing}; use std::str::FromStr; use std::{collections::HashMap, error::Error, io}; diff --git a/rust/agama-cli/src/main.rs b/rust/agama-cli/src/main.rs index df1bdd1892..bb94c02e7e 100644 --- a/rust/agama-cli/src/main.rs +++ b/rust/agama-cli/src/main.rs @@ -8,15 +8,15 @@ mod profile; mod progress; use crate::error::CliError; -use async_std::task::{self, block_on}; -use commands::Commands; -use config::run as run_config_cmd; use agama_lib::error::ServiceError; use agama_lib::manager::ManagerClient; use agama_lib::progress::build_progress_monitor; +use async_std::task::{self, block_on}; +use commands::Commands; +use config::run as run_config_cmd; use printers::Format; -use progress::InstallerProgress; use profile::run as run_profile_cmd; +use progress::InstallerProgress; use std::error::Error; use std::time::Duration; @@ -58,7 +58,10 @@ async fn show_progress() -> Result<(), ServiceError> { let conn = agama_lib::connection().await?; let mut monitor = build_progress_monitor(conn).await.unwrap(); let presenter = InstallerProgress::new(); - monitor.run(presenter).await.expect("failed to monitor the progress"); + monitor + .run(presenter) + .await + .expect("failed to monitor the progress"); Ok(()) } diff --git a/rust/agama-cli/src/profile.rs b/rust/agama-cli/src/profile.rs index b330460108..35eddf2b24 100644 --- a/rust/agama-cli/src/profile.rs +++ b/rust/agama-cli/src/profile.rs @@ -1,7 +1,7 @@ -use clap::Subcommand; use agama_lib::error::ProfileError; use agama_lib::profile::{download, ProfileEvaluator, ProfileValidator, ValidationResult}; -use std::{path::Path}; +use clap::Subcommand; +use std::path::Path; #[derive(Subcommand, Debug)] pub enum ProfileCommands { diff --git a/rust/agama-dbus-server/Cargo.toml b/rust/agama-dbus-server/Cargo.toml index b478b0d727..3604bb06d9 100644 --- a/rust/agama-dbus-server/Cargo.toml +++ b/rust/agama-dbus-server/Cargo.toml @@ -10,6 +10,9 @@ anyhow = "1.0" agama-locale-data = { path="../agama-locale-data" } agama-network = { path="../agama-network" } agama-lib = { path="../agama-lib" } +log = "0.4" +simplelog = "0.12.1" +systemd-journal-logger = "1.0" zbus = "3.7.0" zbus_macros = "3.7.0" async-std = { version = "1.12.0", features = ["attributes"]} diff --git a/rust/agama-dbus-server/src/main.rs b/rust/agama-dbus-server/src/main.rs index 0ce8c23a0b..f5762adfe2 100644 --- a/rust/agama-dbus-server/src/main.rs +++ b/rust/agama-dbus-server/src/main.rs @@ -3,16 +3,36 @@ pub mod locale; pub mod questions; use agama_network::NetworkService; +use log::LevelFilter; use std::future::pending; const ADDRESS: &str = "unix:path=/run/agama/bus"; #[async_std::main] async fn main() -> Result<(), Box> { + // be smart with logging and log directly to journal if connected to it + if systemd_journal_logger::connected_to_journal() { + // unwrap here is intentional as we are sure no other logger is active yet + systemd_journal_logger::JournalLog::default() + .install() + .unwrap(); + log::set_max_level(LevelFilter::Info); // log only info for journal logger + } else { + simplelog::TermLogger::init( + LevelFilter::Info, // lets use info, trace provides too much output from libraries + simplelog::Config::default(), + simplelog::TerminalMode::Stderr, // only stderr output for easier filtering + simplelog::ColorChoice::Auto, + ) + .unwrap(); // unwrap here as we are sure no other logger active + } // When adding more services here, the order might be important. crate::questions::start_service(ADDRESS).await?; + log::info!("Started questions interface"); let _conn = crate::locale::start_service(ADDRESS).await?; + log::info!("Started locale interface"); NetworkService::start(ADDRESS).await?; + log::info!("Started network interface"); // Do other things or go to wait forever pending::<()>().await; diff --git a/rust/agama-lib/Cargo.toml b/rust/agama-lib/Cargo.toml index bfccf63cf1..2154f67820 100644 --- a/rust/agama-lib/Cargo.toml +++ b/rust/agama-lib/Cargo.toml @@ -6,15 +6,16 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -zbus = "3.7.0" -serde = { version = "1.0.152", features = ["derive"] } agama-derive = { path="../agama-derive" } +anyhow = "1.0" async-std = "1.12.0" curl = { version = "0.4.44", features = ["protocol-ftp"] } +futures = "0.3.27" +futures-util = "0.3.27" jsonschema = { version = "0.16.1", default-features = false } +log = "0.4" +serde = { version = "1.0.152", features = ["derive"] } serde_json = "1.0.94" tempfile = "3.4.0" thiserror = "1.0.39" -anyhow = "1.0" -futures = "0.3.27" -futures-util = "0.3.27" +zbus = "3.7.0" \ No newline at end of file diff --git a/rust/agama-lib/src/profile.rs b/rust/agama-lib/src/profile.rs index ccbb618399..0f17953f88 100644 --- a/rust/agama-lib/src/profile.rs +++ b/rust/agama-lib/src/profile.rs @@ -1,6 +1,7 @@ use crate::error::ProfileError; use curl::easy::Easy; use jsonschema::JSONSchema; +use log::info; use serde_json; use std::{ fs, io, @@ -10,7 +11,7 @@ use std::{ }; use tempfile::tempdir; -/// Downloads a file a writes it to the stdout() +/// Downloads a file and writes it to the stdout() /// /// TODO: move this code to a struct /// TODO: add support for YaST-specific URLs @@ -65,6 +66,7 @@ impl ProfileValidator { } else { Path::new("/usr/share/agama-cli/profile.schema.json") }; + info!("Validation with path {}", path.to_str().unwrap()); Self::new(path) } diff --git a/rust/agama-lib/src/store/software.rs b/rust/agama-lib/src/store/software.rs index 4c49c1321c..f446f972e4 100644 --- a/rust/agama-lib/src/store/software.rs +++ b/rust/agama-lib/src/store/software.rs @@ -31,9 +31,11 @@ impl<'a> SoftwareStore<'a> { if ids.contains(&product) { self.software_client.select_product(product).await?; } else { - return Err(Box::new(WrongParameter::UnknownProduct(product.clone(), ids))); + return Err(Box::new(WrongParameter::UnknownProduct( + product.clone(), + ids, + ))); } - } Ok(()) } diff --git a/rust/agama-lib/src/store/users.rs b/rust/agama-lib/src/store/users.rs index d2762645c4..a4dfa841d1 100644 --- a/rust/agama-lib/src/store/users.rs +++ b/rust/agama-lib/src/store/users.rs @@ -1,6 +1,6 @@ +use crate::error::WrongParameter; use crate::install_settings::{FirstUserSettings, RootUserSettings, UserSettings}; use crate::users::{FirstUser, UsersClient}; -use crate::error::WrongParameter; use std::error::Error; use zbus::Connection; @@ -57,7 +57,7 @@ impl<'a> UsersStore<'a> { }; let (success, issues) = self.users_client.set_first_user(&first_user).await?; if !success { - return Err(Box::new(WrongParameter::WrongUser(issues))); + return Err(Box::new(WrongParameter::WrongUser(issues))); } Ok(()) } diff --git a/rust/agama-lib/src/users.rs b/rust/agama-lib/src/users.rs index 10c36a1d3d..d88ab3a76a 100644 --- a/rust/agama-lib/src/users.rs +++ b/rust/agama-lib/src/users.rs @@ -78,10 +78,7 @@ impl<'a> UsersClient<'a> { value: &str, encrypted: bool, ) -> Result { - Ok(self - .users_proxy - .set_root_password(value, encrypted) - .await?) + Ok(self.users_proxy.set_root_password(value, encrypted).await?) } /// Whether the root password is set or not diff --git a/rust/agama-locale-data/src/deprecated_timezones.rs b/rust/agama-locale-data/src/deprecated_timezones.rs index 403f210859..a4a0fbc3b0 100644 --- a/rust/agama-locale-data/src/deprecated_timezones.rs +++ b/rust/agama-locale-data/src/deprecated_timezones.rs @@ -1,19 +1,19 @@ /// List of timezones which are deprecated and langtables missing translations for it -/// +/// /// Filtering it out also helps with returning smaller list of real timezones. /// Sadly many libraries facing issues with deprecated timezones, see e.g. -/// -pub(crate) const DEPRECATED_TIMEZONES : &[&str]= &[ - "Africa/Asmera", // replaced by Africa/Asmara - "Africa/Timbuktu", // replaced by Africa/Bamako +/// +pub(crate) const DEPRECATED_TIMEZONES: &[&str] = &[ + "Africa/Asmera", // replaced by Africa/Asmara + "Africa/Timbuktu", // replaced by Africa/Bamako "America/Argentina/ComodRivadavia", // replaced by America/Argentina/Catamarca - "America/Atka", // replaced by America/Adak - "America/Ciudad_Juarez", // failed to find replacement - "America/Coral_Harbour", // replaced by America/Atikokan - "America/Ensenada", // replaced by America/Tijuana + "America/Atka", // replaced by America/Adak + "America/Ciudad_Juarez", // failed to find replacement + "America/Coral_Harbour", // replaced by America/Atikokan + "America/Ensenada", // replaced by America/Tijuana "America/Fort_Nelson", "America/Fort_Wayne", // replaced by America/Indiana/Indianapolis - "America/Knox_IN", // replaced by America/Indiana/Knox + "America/Knox_IN", // replaced by America/Indiana/Knox "America/Nuuk", "America/Porto_Acre", // replaced by America/Rio_Branco "America/Punta_Arenas", @@ -170,4 +170,4 @@ pub(crate) const DEPRECATED_TIMEZONES : &[&str]= &[ "W-SU", "WET", "Zulu", -]; \ No newline at end of file +]; diff --git a/rust/agama-locale-data/src/language.rs b/rust/agama-locale-data/src/language.rs index 8502459307..7eebe7a7d6 100644 --- a/rust/agama-locale-data/src/language.rs +++ b/rust/agama-locale-data/src/language.rs @@ -1,6 +1,6 @@ use serde::Deserialize; -use crate::ranked::{RankedTerritories, RankedLocales}; +use crate::ranked::{RankedLocales, RankedTerritories}; #[derive(Debug, Deserialize)] pub struct Language { @@ -8,16 +8,16 @@ pub struct Language { pub id: String, pub territories: RankedTerritories, pub locales: RankedLocales, - pub names: crate::localization::Localization + pub names: crate::localization::Localization, } #[derive(Debug, Deserialize)] pub struct Languages { - pub language: Vec + pub language: Vec, } impl Languages { pub fn find_by_id(&self, id: &str) -> Option<&Language> { self.language.iter().find(|t| t.id == id) } -} \ No newline at end of file +} diff --git a/rust/agama-locale-data/src/lib.rs b/rust/agama-locale-data/src/lib.rs index 4a10c2489d..0fe0803915 100644 --- a/rust/agama-locale-data/src/lib.rs +++ b/rust/agama-locale-data/src/lib.rs @@ -1,20 +1,20 @@ use anyhow::Context; +use flate2::bufread::GzDecoder; +use quick_xml::de::Deserializer; +use regex::Regex; use serde::Deserialize; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::process::Command; -use quick_xml::de::Deserializer; -use flate2::bufread::GzDecoder; -use regex::Regex; -pub mod xkeyboard; +pub mod deprecated_timezones; pub mod language; pub mod localization; +pub mod ranked; pub mod territory; pub mod timezone_part; -pub mod ranked; -pub mod deprecated_timezones; +pub mod xkeyboard; fn file_reader(file_path: &str) -> anyhow::Result { let file = File::open(file_path) @@ -34,37 +34,45 @@ pub fn get_xkeyboards() -> anyhow::Result { } /// Gets list of available keymaps -/// +/// /// ## Examples /// Requires working localectl. -/// +/// /// ```no_run /// let key_maps = agama_locale_data::get_key_maps().unwrap(); /// assert!(key_maps.contains(&"us".to_string())) /// ``` pub fn get_key_maps() -> anyhow::Result> { const BINARY: &str = "/usr/bin/localectl"; - let output = Command::new(BINARY).arg("list-keymaps") - .output().context("failed to execute localectl list-maps")?.stdout; + let output = Command::new(BINARY) + .arg("list-keymaps") + .output() + .context("failed to execute localectl list-maps")? + .stdout; let output = String::from_utf8(output).context("Strange localectl output formatting")?; let ret = output.split('\n').map(|l| l.trim().to_string()).collect(); - + Ok(ret) } /// Parses given locale to language and territory part -/// +/// /// /// ## Examples -/// +/// /// ``` /// let result = agama_locale_data::parse_locale("en_US.UTF-8").unwrap(); /// assert_eq!(result.0, "en"); /// assert_eq!(result.1, "US") /// ``` pub fn parse_locale(locale: &str) -> anyhow::Result<(&str, &str)> { - let locale_regexp : Regex = Regex::new(r"^([[:alpha:]]+)_([[:alpha:]]+)").unwrap(); - let captures = locale_regexp.captures(locale).context("Failed to parse locale")?; - Ok((captures.get(1).unwrap().as_str(), captures.get(2).unwrap().as_str())) + let locale_regexp: Regex = Regex::new(r"^([[:alpha:]]+)_([[:alpha:]]+)").unwrap(); + let captures = locale_regexp + .captures(locale) + .context("Failed to parse locale")?; + Ok(( + captures.get(1).unwrap().as_str(), + captures.get(2).unwrap().as_str(), + )) } /// Returns struct which contain list of known languages @@ -97,13 +105,13 @@ pub fn get_timezone_parts() -> anyhow::Result { Ok(ret) } - /// Gets list of non-deprecated timezones pub fn get_timezones() -> Vec { - chrono_tz::TZ_VARIANTS.iter() - .filter(|&tz| !crate::deprecated_timezones::DEPRECATED_TIMEZONES.contains(&tz.name())) // Filter out deprecated asmera - .map(|e| e.name().to_string()) - .collect() + chrono_tz::TZ_VARIANTS + .iter() + .filter(|&tz| !crate::deprecated_timezones::DEPRECATED_TIMEZONES.contains(&tz.name())) // Filter out deprecated asmera + .map(|e| e.name().to_string()) + .collect() } #[cfg(test)] @@ -152,7 +160,10 @@ mod tests { // here test that timezones from timezones matches ones in langtable ( as timezones can contain deprecated ones) // so this test catch if there is new zone that is not translated or if a zone is become deprecated let timezones = get_timezones(); - let localized = get_timezone_parts().unwrap().localize_timezones("de", &timezones); - let _res : Vec<(String, String)> = timezones.into_iter().zip(localized.into_iter()).collect(); + let localized = get_timezone_parts() + .unwrap() + .localize_timezones("de", &timezones); + let _res: Vec<(String, String)> = + timezones.into_iter().zip(localized.into_iter()).collect(); } } diff --git a/rust/agama-locale-data/src/localization.rs b/rust/agama-locale-data/src/localization.rs index a3622589a9..33167a0cff 100644 --- a/rust/agama-locale-data/src/localization.rs +++ b/rust/agama-locale-data/src/localization.rs @@ -2,13 +2,12 @@ use serde::Deserialize; #[derive(Debug, Deserialize)] pub struct Localization { - pub name: Vec + pub name: Vec, } impl Localization { pub fn name_for(&self, language: &str) -> Option { - let entry = self.name.iter() - .find(|n| n.language == language)?; + let entry = self.name.iter().find(|n| n.language == language)?; Some(entry.value.clone()) } } @@ -18,5 +17,5 @@ pub struct LocalizationEntry { #[serde(rename(deserialize = "languageId"))] pub language: String, #[serde(rename(deserialize = "trName"))] - pub value: String -} \ No newline at end of file + pub value: String, +} diff --git a/rust/agama-locale-data/src/ranked.rs b/rust/agama-locale-data/src/ranked.rs index f5d26a2c60..217648ca60 100644 --- a/rust/agama-locale-data/src/ranked.rs +++ b/rust/agama-locale-data/src/ranked.rs @@ -6,13 +6,13 @@ pub struct RankedLanguage { #[serde(rename(deserialize = "languageId"))] pub id: String, /// Bigger rank means it is more important - pub rank: u16 + pub rank: u16, } #[derive(Debug, Deserialize)] pub struct RankedLanguages { #[serde(default)] - pub language: Vec + pub language: Vec, } #[derive(Debug, Deserialize)] @@ -20,24 +20,24 @@ pub struct RankedTerritory { #[serde(rename(deserialize = "territoryId"))] pub id: String, /// Bigger rank means it is more important - pub rank: u16 + pub rank: u16, } #[derive(Debug, Deserialize)] pub struct RankedTerritories { #[serde(default)] - pub territory: Vec + pub territory: Vec, } #[derive(Debug, Deserialize)] pub struct RankedLocale { #[serde(rename(deserialize = "localeId"))] pub id: String, - pub rank: u16 + pub rank: u16, } #[derive(Debug, Deserialize)] pub struct RankedLocales { #[serde(default)] - pub locale: Vec + pub locale: Vec, } diff --git a/rust/agama-locale-data/src/territory.rs b/rust/agama-locale-data/src/territory.rs index 209afbe2b5..f8f8eda0ce 100644 --- a/rust/agama-locale-data/src/territory.rs +++ b/rust/agama-locale-data/src/territory.rs @@ -5,16 +5,16 @@ pub struct Territory { #[serde(rename(deserialize = "territoryId"))] pub id: String, pub languages: crate::ranked::RankedLanguages, - pub names: crate::localization::Localization + pub names: crate::localization::Localization, } #[derive(Debug, Deserialize)] pub struct Territories { - pub territory: Vec + pub territory: Vec, } impl Territories { pub fn find_by_id(&self, id: &str) -> Option<&Territory> { self.territory.iter().find(|t| t.id == id) } -} \ No newline at end of file +} diff --git a/rust/agama-locale-data/src/xkeyboard.rs b/rust/agama-locale-data/src/xkeyboard.rs index b762aead83..e52edf7ef0 100644 --- a/rust/agama-locale-data/src/xkeyboard.rs +++ b/rust/agama-locale-data/src/xkeyboard.rs @@ -1,6 +1,6 @@ use serde::Deserialize; -use crate::ranked::{RankedTerritories, RankedLanguages}; +use crate::ranked::{RankedLanguages, RankedTerritories}; #[derive(Debug, Deserialize)] pub struct XKeyboard { @@ -12,10 +12,10 @@ pub struct XKeyboard { pub ascii: bool, pub comment: Option, pub languages: RankedLanguages, - pub territories: RankedTerritories + pub territories: RankedTerritories, } #[derive(Debug, Deserialize)] pub struct XKeyboards { - pub keyboard: Vec + pub keyboard: Vec, } diff --git a/rust/agama-network/src/dbus/tree.rs b/rust/agama-network/src/dbus/tree.rs index 4dc17404c8..9dbea939ea 100644 --- a/rust/agama-network/src/dbus/tree.rs +++ b/rust/agama-network/src/dbus/tree.rs @@ -36,10 +36,7 @@ impl Tree { /// adding/removing interfaces. We should add/update/delete objects as needed. /// /// * `connections`: list of connections. - pub async fn set_connections( - &self, - connections: &Vec, - ) -> Result<(), ServiceError> { + pub async fn set_connections(&self, connections: &Vec) -> Result<(), ServiceError> { self.remove_connections().await?; self.add_connections(connections).await?; Ok(()) diff --git a/rust/agama-network/src/system.rs b/rust/agama-network/src/system.rs index f173b4e7cb..c92eca4457 100644 --- a/rust/agama-network/src/system.rs +++ b/rust/agama-network/src/system.rs @@ -58,9 +58,7 @@ impl NetworkSystem { /// Populates the D-Bus tree with the known devices and connections. pub async fn setup(&mut self) -> Result<(), ServiceError> { - self.tree - .set_connections(&self.state.connections) - .await?; + self.tree.set_connections(&self.state.connections).await?; self.tree.set_devices(&self.state.devices).await?; Ok(()) } @@ -95,9 +93,7 @@ impl NetworkSystem { self.to_network_manager().await?; // TODO: re-creating the tree is kind of brute-force and it sends signals about // adding/removing interfaces. We should add/update/delete objects as needed. - self.tree - .set_connections(&self.state.connections) - .await?; + self.tree.set_connections(&self.state.connections).await?; } }