From a2693c7046d4da96578cbb609807283959b8646f Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 17 May 2024 10:57:35 +0200 Subject: [PATCH] section-config: pass filesystem paths as AsRef Signed-off-by: Dietmar Maurer --- proxmox-section-config/src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/proxmox-section-config/src/lib.rs b/proxmox-section-config/src/lib.rs index 4441df12..2e9d237b 100644 --- a/proxmox-section-config/src/lib.rs +++ b/proxmox-section-config/src/lib.rs @@ -18,6 +18,7 @@ //! ... //! ``` +use std::path::Path; use std::collections::HashMap; use std::collections::HashSet; @@ -306,9 +307,9 @@ impl SectionConfig { /// This verifies the whole data using the schemas defined in the /// plugins. Please note that `filename` is only used to improve /// error messages. - pub fn write(&self, filename: &str, config: &SectionConfigData) -> Result { + pub fn write>(&self, filename: P, config: &SectionConfigData) -> Result { self.write_do(config) - .map_err(|e: Error| format_err!("writing '{}' failed: {}", filename, e)) + .map_err(|e: Error| format_err!("writing {:?} failed: {}", filename.as_ref(), e)) } fn write_do(&self, config: &SectionConfigData) -> Result { @@ -393,7 +394,7 @@ impl SectionConfig { /// This verifies the whole data using the schemas defined in the /// plugins. Please note that `filename` is only used to improve /// error messages. - pub fn parse(&self, filename: &str, raw: &str) -> Result { + pub fn parse>(&self, filename: P, raw: &str) -> Result { let mut state = ParseState::BeforeHeader; let test_required_properties = |value: &Value, @@ -572,7 +573,7 @@ impl SectionConfig { Ok(result) }) - .map_err(|e: Error| format_err!("parsing '{}' failed: {}", filename, e)) + .map_err(|e: Error| format_err!("parsing {:?} failed: {}", filename.as_ref(), e)) } fn default_format_section_header(