diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-04-03 22:04:24 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-04-03 22:04:24 +0200 |
commit | 15f3c2d0996349284a02a7e20048b9ce511414e0 (patch) | |
tree | 47a78418408e5b95ec49693faf6ddb672c41a18e /src | |
parent | 338e62ab4094fb203092119b0da93c65d0e152ae (diff) |
Add import()
Diffstat (limited to 'src')
-rw-r--r-- | src/import.rs | 14 | ||||
-rw-r--r-- | src/lib.rs | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/import.rs b/src/import.rs new file mode 100644 index 0000000..69a0aad --- /dev/null +++ b/src/import.rs @@ -0,0 +1,14 @@ +use std::io::Read; + +use serde_json; + +use result::Result; +use task::Task; +use error::{TaskError, TaskErrorKind}; + +pub fn import<R: Read>(r: R) -> Result<Vec<Task>> { + serde_json::from_reader(r) + .map_err(|e| { + TaskError::new(TaskErrorKind::ParserError, Some(Box::new(e))) + }) +} @@ -7,6 +7,7 @@ extern crate uuid; pub mod core; pub mod date; pub mod error; +pub mod import; pub mod priority; pub mod project; pub mod result; |