diff options
author | Radosław Kot <rdkt13@gmail.com> | 2021-07-31 16:40:52 +0200 |
---|---|---|
committer | Radosław Kot <rdkt13@gmail.com> | 2021-10-23 16:58:41 +0200 |
commit | abe7f7624a02261cde994d5128d44c63fe65dd60 (patch) | |
tree | 9998f76719a0a35b956952522fac22c1309fea81 /src/file/source/string.rs | |
parent | 0cf715faf39ce0ac28e228eeb4874c374e1f0594 (diff) |
Make File generic over Format and FileExtensions
Diffstat (limited to 'src/file/source/string.rs')
-rw-r--r-- | src/file/source/string.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/file/source/string.rs b/src/file/source/string.rs index 2fede45..9bec751 100644 --- a/src/file/source/string.rs +++ b/src/file/source/string.rs @@ -1,6 +1,7 @@ use std::error::Error; -use crate::file::{FileFormat, FileSource}; +use crate::file::{FileExtensions, FileSource}; +use crate::Format; /// Describes a file sourced from a string #[derive(Clone, Debug)] @@ -12,15 +13,18 @@ impl<'a> From<&'a str> for FileSourceString { } } -impl FileSource for FileSourceString { +impl<F> FileSource<F> for FileSourceString +where + F: Format + FileExtensions + 'static, +{ fn resolve( &self, - format_hint: Option<FileFormat>, - ) -> Result<(Option<String>, String, FileFormat), Box<dyn Error + Send + Sync>> { + format_hint: Option<F>, + ) -> Result<(Option<String>, String, Box<dyn Format>), Box<dyn Error + Send + Sync>> { Ok(( None, self.0.clone(), - format_hint.expect("from_str requires a set file format"), + Box::new(format_hint.expect("from_str requires a set file format")), )) } } |