From bfc44c331a77d8c341c076e72df5ed0b56fbd422 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Thu, 1 Jun 2017 23:22:04 -0700 Subject: Move things around and get some tests in place --- src/file/source/string.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/file/source/string.rs (limited to 'src/file/source/string.rs') 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) -> Result<(Option, String), Box> { + Ok((None, self.0.clone())) + } +} -- cgit v1.2.3