summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadosław Kot <rdkt13@gmail.com>2021-07-31 13:24:00 +0200
committerRadosław Kot <rdkt13@gmail.com>2021-10-23 16:58:41 +0200
commit0cf715faf39ce0ac28e228eeb4874c374e1f0594 (patch)
tree50bb4a7057758b4453496a2bde74bec89fe56431
parent63c16af26852cbabd56b145e952dcca8ec1522b4 (diff)
Implement FileExtensions trait for FileFormat
-rw-r--r--src/file/format/mod.rs8
-rw-r--r--src/format.rs3
2 files changed, 6 insertions, 5 deletions
diff --git a/src/file/format/mod.rs b/src/file/format/mod.rs
index 47b856d..d1a9a71 100644
--- a/src/file/format/mod.rs
+++ b/src/file/format/mod.rs
@@ -6,7 +6,7 @@ use std::collections::HashMap;
use std::error::Error;
use crate::map::Map;
-use crate::{value::Value, Format};
+use crate::{value::Value, Format, file::extension::FileExtensions};
#[cfg(feature = "toml")]
mod toml;
@@ -84,11 +84,11 @@ lazy_static! {
impl FileFormat {
// TODO: pub(crate)
#[doc(hidden)]
- pub fn extensions(self) -> &'static Vec<&'static str> {
+ pub fn extensions(&self) -> &'static Vec<&'static str> {
// It should not be possible for this to fail
// A FileFormat would need to be declared without being added to the
// ALL_EXTENSIONS map.
- ALL_EXTENSIONS.get(&self).unwrap()
+ ALL_EXTENSIONS.get(self).unwrap()
}
// TODO: pub(crate)
@@ -126,7 +126,7 @@ impl Format for FileFormat {
&self,
uri: Option<&String>,
text: &str,
- ) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> {
+ ) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>> {
self.parse(uri, text)
}
}
diff --git a/src/format.rs b/src/format.rs
index 9d666c4..c32dbae 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -1,11 +1,12 @@
use std::{collections::HashMap, error::Error};
use crate::value::Value;
+use crate::map::Map;
pub trait Format {
fn parse(
&self,
uri: Option<&String>,
text: &str,
- ) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>>;
+ ) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>>;
}