diff options
author | Ryan Leckey <ryan@launchbadge.com> | 2017-06-13 18:55:40 -0700 |
---|---|---|
committer | Ryan Leckey <ryan@launchbadge.com> | 2017-06-13 18:55:40 -0700 |
commit | 47ad966e064f842056e7c1b7abe8ef64d127f5be (patch) | |
tree | 4dd4e14168383dd818fe6add8ed0a5f4900d85b6 /src/file/source/string.rs | |
parent | 1266d110ba31a9d0f9f4908a5a30291899ffc8fc (diff) | |
parent | 312f32905f518fa59e1daf3fc8224dadf584b484 (diff) |
Merge branch 'serde'
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())) + } +} |