diff options
author | Ryan Leckey <ryan@launchbadge.com> | 2017-06-01 23:22:04 -0700 |
---|---|---|
committer | Ryan Leckey <ryan@launchbadge.com> | 2017-06-01 23:22:04 -0700 |
commit | bfc44c331a77d8c341c076e72df5ed0b56fbd422 (patch) | |
tree | c757723957be6b880d1e0d8d26ae2b1c9c606ed2 /src/file/source/string.rs | |
parent | 4357840e95f3646494ddeea4aae12425dfab2db8 (diff) |
Move things around and get some tests in place
Diffstat (limited to 'src/file/source/string.rs')
-rw-r--r-- | src/file/source/string.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/file/source/string.rs b/src/file/source/string.rs new file mode 100644 index 0000000..e1d9f64 --- /dev/null +++ b/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())) + } +} |