diff options
Diffstat (limited to 'src/format.rs')
-rw-r--r-- | src/format.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/format.rs b/src/format.rs new file mode 100644 index 0000000..d2fe494 --- /dev/null +++ b/src/format.rs @@ -0,0 +1,24 @@ +use std::{collections::HashMap, error::Error};
+
+use crate::value::Value;
+
+pub trait Format {
+ fn parse(
+ self,
+ uri: Option<&String>,
+ text: &str,
+ ) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>>;
+}
+
+impl<F> Format for F
+where
+ F: Fn(Option<&String>, &str) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>>
+{
+ fn parse(
+ self,
+ uri: Option<&String>,
+ text: &str,
+ ) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> {
+ self(uri, text)
+ }
+}
\ No newline at end of file |