libimagtodo: Replace read with typed read
This commit is contained in:
parent
397f79b238
commit
13ff09d8c6
1 changed files with 4 additions and 6 deletions
|
@ -25,7 +25,7 @@ use error::Result;
|
||||||
use libimagstore::store::Entry;
|
use libimagstore::store::Entry;
|
||||||
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use toml_query::read::TomlValueReadExt;
|
use toml_query::read::TomlValueReadTypeExt;
|
||||||
|
|
||||||
pub trait Task {
|
pub trait Task {
|
||||||
fn get_uuid(&self) -> Result<Uuid>;
|
fn get_uuid(&self) -> Result<Uuid>;
|
||||||
|
@ -34,12 +34,10 @@ pub trait Task {
|
||||||
impl Task for Entry {
|
impl Task for Entry {
|
||||||
fn get_uuid(&self) -> Result<Uuid> {
|
fn get_uuid(&self) -> Result<Uuid> {
|
||||||
self.get_header()
|
self.get_header()
|
||||||
.read("todo.uuid")
|
.read_string("todo.uuid")
|
||||||
.chain_err(|| TEK::StoreError)?
|
.chain_err(|| TEK::StoreError)?
|
||||||
.ok_or(TE::from_kind(TEK::HeaderFieldMissing))?
|
.ok_or(TE::from_kind(TEK::HeaderFieldMissing))
|
||||||
.as_str()
|
.and_then(|u| Uuid::parse_str(&u).chain_err(|| TEK::UuidParserError))
|
||||||
.ok_or(TE::from_kind(TEK::HeaderTypeError))
|
|
||||||
.and_then(|u| Uuid::parse_str(u).chain_err(|| TEK::UuidParserError))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue