diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-08-28 09:54:25 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2017-08-28 14:32:50 +0200 |
commit | 6d40797a0755ada383261896605cab75ac2c3ecc (patch) | |
tree | a7ee6f52502cacb4bdfd7862a188f287a5610099 /lib/domain/libimagmail | |
parent | d58b97fdf1cf979720a01f8d23f3ce0c59c4eafc (diff) |
Fix libimagmail to use new libimagentryref interface
Diffstat (limited to 'lib/domain/libimagmail')
-rw-r--r-- | lib/domain/libimagmail/src/iter.rs | 14 | ||||
-rw-r--r-- | lib/domain/libimagmail/src/mail.rs | 16 |
2 files changed, 16 insertions, 14 deletions
diff --git a/lib/domain/libimagmail/src/iter.rs b/lib/domain/libimagmail/src/iter.rs index fe1e72a4..6fee9e64 100644 --- a/lib/domain/libimagmail/src/iter.rs +++ b/lib/domain/libimagmail/src/iter.rs @@ -27,16 +27,17 @@ use mail::Mail; use result::Result; +use libimagstore::store::FileLockEntry; use libimagentryref::reference::Ref; use std::marker::PhantomData; -pub struct MailIter<'a, I: 'a + Iterator<Item = Ref<'a>>> { - _marker: PhantomData<&'a I>, +pub struct MailIter<'a, I: Iterator<Item = FileLockEntry<'a>>> { + _marker: PhantomData<I>, i: I, } -impl<'a, I: Iterator<Item = Ref<'a>>> MailIter<'a, I> { +impl<'a, I: Iterator<Item = FileLockEntry<'a>>> MailIter<'a, I> { pub fn new(i: I) -> MailIter<'a, I> { MailIter { _marker: PhantomData, i: i } @@ -44,12 +45,11 @@ impl<'a, I: Iterator<Item = Ref<'a>>> MailIter<'a, I> { } -impl<'a, I: Iterator<Item = Ref<'a>>> Iterator for MailIter<'a, I> { - +impl<'a, I: Iterator<Item = FileLockEntry<'a>>> Iterator for MailIter<'a, I> { type Item = Result<Mail<'a>>; - fn next(&mut self) -> Option<Result<Mail<'a>>> { - self.i.next().map(Mail::from_ref) + fn next(&mut self) -> Option<Self::Item> { + self.i.next().map(Mail::from_fle) } } diff --git a/lib/domain/libimagmail/src/mail.rs b/lib/domain/libimagmail/src/mail.rs index 11b57398..d5f02cdf 100644 --- a/lib/domain/libimagmail/src/mail.rs +++ b/lib/domain/libimagmail/src/mail.rs @@ -23,8 +23,10 @@ use std::fs::File; use std::io::Read; use libimagstore::store::Store; +use libimagstore::store::FileLockEntry; use libimagentryref::reference::Ref; use libimagentryref::flags::RefFlags; +use libimagentryref::refstore::RefStore; use email::MimeMessage; use email::results::ParsingResult as EmailParsingResult; @@ -47,7 +49,7 @@ impl From<String> for Buffer { } } -pub struct Mail<'a>(Ref<'a>, Buffer); +pub struct Mail<'a>(FileLockEntry<'a>, Buffer); impl<'a> Mail<'a> { @@ -57,7 +59,7 @@ impl<'a> Mail<'a> { let f = RefFlags::default().with_content_hashing(true).with_permission_tracking(false); let p = PathBuf::from(p.as_ref()); - Ref::create_with_hasher(store, p, f, h) + store.create_with_hasher(p, f, h) .map_err_into(MEK::RefCreationError) .and_then(|reference| { reference.fs_file() @@ -76,19 +78,19 @@ impl<'a> Mail<'a> { /// Opens a mail by the passed hash pub fn open<S: AsRef<str>>(store: &Store, hash: S) -> Result<Option<Mail>> { - Ref::get_by_hash(store, String::from(hash.as_ref())) + store.get_by_hash(String::from(hash.as_ref())) .map_err_into(MEK::FetchByHashError) .map_err_into(MEK::FetchError) .and_then(|o| match o { - Some(r) => Mail::from_ref(r).map(Some), + Some(r) => Mail::from_fle(r).map(Some), None => Ok(None), }) } /// Implement me as TryFrom as soon as it is stable - pub fn from_ref(r: Ref<'a>) -> Result<Mail> { - r.fs_file() + pub fn from_fle(fle: FileLockEntry<'a>) -> Result<Mail<'a>> { + fle.fs_file() .map_err_into(MEK::RefHandlingError) .and_then(|path| File::open(path).map_err_into(MEK::IOError)) .and_then(|mut file| { @@ -98,7 +100,7 @@ impl<'a> Mail<'a> { .map_err_into(MEK::IOError) }) .map(Buffer::from) - .map(|buffer| Mail(r, buffer)) + .map(|buffer| Mail(fle, buffer)) } pub fn get_field(&self, field: &str) -> Result<Option<String>> { |