diff options
Diffstat (limited to 'lib/src/file/source/string.rs')
-rw-r--r-- | lib/src/file/source/string.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/src/file/source/string.rs b/lib/src/file/source/string.rs new file mode 100644 index 0000000..e1d9f64 --- /dev/null +++ b/lib/src/file/source/string.rs @@ -0,0 +1,21 @@ +use std::str::FromStr; +use std::result; +use std::error::Error; + +use source::Source; +use super::{FileSource, FileFormat}; + +/// Describes a file sourced from a string +pub struct FileSourceString(String); + +impl<'a> From<&'a str> for FileSourceString { + fn from(s: &'a str) -> Self { + FileSourceString(s.into()) + } +} + +impl FileSource for FileSourceString { + fn resolve(&self, _: Option<FileFormat>) -> Result<(Option<String>, String), Box<Error>> { + Ok((None, self.0.clone())) + } +} |