From 1575e7c8aa23039f241ae54f03e5752451d04b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Tue, 30 Aug 2022 15:33:22 +0200 Subject: [PATCH] roezio/config: move set method alongside get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- src/config.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4d43f2b5..fe8f8c04 100644 --- a/src/config.rs +++ b/src/config.rs @@ -158,21 +158,6 @@ impl<'a> Config<'a> { } } - /// Sets a key/value pair in memory and updates the config file. - pub(crate) fn set( - &mut self, - key: &str, - value: ConfigValue, - section: Option, - ) -> Result<(), Error> { - let section: String = section - .map(|jid| jid.to_string()) - .unwrap_or(String::from("default")); - self.write_to_file(key.clone(), value.clone(), section.as_str())?; - let _ = self.ini.set(section.as_str(), key, Some(value.to_string())); - Ok(()) - } - fn parse( mut reader: R, key: String, @@ -300,6 +285,21 @@ impl<'a> Config<'a> { Ok(()) } + /// Sets a key/value pair in memory and updates the config file. + pub(crate) fn set( + &mut self, + key: &str, + value: ConfigValue, + section: Option, + ) -> Result<(), Error> { + let section: String = section + .map(|jid| jid.to_string()) + .unwrap_or(String::from("default")); + self.write_to_file(key.clone(), value.clone(), section.as_str())?; + let _ = self.ini.set(section.as_str(), key, Some(value.to_string())); + Ok(()) + } + /// Fetches a value pub(crate) fn get( &self,