From 0cf715faf39ce0ac28e228eeb4874c374e1f0594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kot?= Date: Sat, 31 Jul 2021 13:24:00 +0200 Subject: Implement FileExtensions trait for FileFormat --- src/file/format/mod.rs | 8 ++++---- src/format.rs | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') 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, Box> { + ) -> Result, Box> { 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, Box>; + ) -> Result, Box>; } -- cgit v1.2.3