summaryrefslogtreecommitdiffstats
path: root/src/file
diff options
context:
space:
mode:
authorRyan Leckey <leckey.ryan@gmail.com>2017-02-12 11:04:30 -0800
committerRyan Leckey <leckey.ryan@gmail.com>2017-02-12 11:04:30 -0800
commite29748b255ce97dfe9b4efcfbc4d9bcb3d694b97 (patch)
tree1b544db4cee3b392463edda743c3513c73f73459 /src/file
parente0fe3e151c24ab81f8d232b3e18841acacc3656e (diff)
Decorate Box<Source> with Send + Sync
Diffstat (limited to 'src/file')
-rw-r--r--src/file/json.rs2
-rw-r--r--src/file/mod.rs12
-rw-r--r--src/file/toml.rs2
-rw-r--r--src/file/yaml.rs2
4 files changed, 9 insertions, 9 deletions
diff --git a/src/file/json.rs b/src/file/json.rs
index 64c6236..e6cc2f4 100644
--- a/src/file/json.rs
+++ b/src/file/json.rs
@@ -11,7 +11,7 @@ pub struct Content {
}
impl Content {
- pub fn parse(text: &str, namespace: Option<&String>) -> Result<Box<Source>, Box<Error>> {
+ pub fn parse(text: &str, namespace: Option<&String>) -> Result<Box<Source + Send + Sync>, Box<Error>> {
// Parse
let mut root: serde_json::Value = serde_json::from_str(text)?;
diff --git a/src/file/mod.rs b/src/file/mod.rs
index 6c72c37..7f7c0fb 100644
--- a/src/file/mod.rs
+++ b/src/file/mod.rs
@@ -47,7 +47,7 @@ impl FileFormat {
}
#[allow(unused_variables)]
- fn parse(&self, text: &str, namespace: Option<&String>) -> Result<Box<Source>, Box<Error>> {
+ fn parse(&self, text: &str, namespace: Option<&String>) -> Result<Box<Source + Send + Sync>, Box<Error>> {
match *self {
#[cfg(feature = "toml")]
FileFormat::Toml => toml::Content::parse(text, namespace),
@@ -65,7 +65,7 @@ pub trait FileSource {
fn try_build(&self,
format: FileFormat,
namespace: Option<&String>)
- -> Result<Box<Source>, Box<Error>>;
+ -> Result<Box<Source + Send + Sync>, Box<Error>>;
}
pub struct FileSourceString(String);
@@ -74,7 +74,7 @@ impl FileSource for FileSourceString {
fn try_build(&self,
format: FileFormat,
namespace: Option<&String>)
- -> Result<Box<Source>, Box<Error>> {
+ -> Result<Box<Source + Send + Sync>, Box<Error>> {
format.parse(&self.0, namespace)
}
}
@@ -132,7 +132,7 @@ impl FileSource for FileSourceFile {
fn try_build(&self,
format: FileFormat,
namespace: Option<&String>)
- -> Result<Box<Source>, Box<Error>> {
+ -> Result<Box<Source + Send + Sync>, Box<Error>> {
// Find file
let filename = self.find_file(format)?;
@@ -195,7 +195,7 @@ impl<T: FileSource> File<T> {
}
// Build normally and return error on failure
- fn try_build(&self) -> Result<Box<Source>, Box<Error>> {
+ fn try_build(&self) -> Result<Box<Source + Send + Sync>, Box<Error>> {
self.source.try_build(self.format, self.namespace.as_ref())
}
}
@@ -209,7 +209,7 @@ impl File<FileSourceFile> {
impl<T: FileSource> SourceBuilder for File<T> {
// Use try_build but only pass an error through if this source
// is required
- fn build(&self) -> Result<Box<Source>, Box<Error>> {
+ fn build(&self) -> Result<Box<Source + Send + Sync>, Box<Error>> {
if self.required {
self.try_build()
} else {
diff --git a/src/file/toml.rs b/src/file/toml.rs
index e3fb0d8..9b07cf0 100644
--- a/src/file/toml.rs
+++ b/src/file/toml.rs
@@ -10,7 +10,7 @@ pub struct Content {
}
impl Content {
- pub fn parse(text: &str, namespace: Option<&String>) -> Result<Box<Source>, Box<Error>> {
+ pub fn parse(text: &str, namespace: Option<&String>) -> Result<Box<Source + Send + Sync>, Box<Error>> {
// Parse
let mut parser = toml::Parser::new(text);
// TODO: Get a solution to make this return an Error-able
diff --git a/src/file/yaml.rs b/src/file/yaml.rs
index 7a70a4e..95a64b4 100644
--- a/src/file/yaml.rs
+++ b/src/file/yaml.rs
@@ -13,7 +13,7 @@ pub struct Content {
}
impl Content {
- pub fn parse(text: &str, namespace: Option<&String>) -> Result<Box<Source>, Box<Error>> {
+ pub fn parse(text: &str, namespace: Option<&String>) -> Result<Box<Source + Send + Sync>, Box<Error>> {
let mut docs = yaml::YamlLoader::load_from_str(text)?;
// Designate root