summaryrefslogtreecommitdiffstats
path: root/lib/domain/libimagmail
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-09-04 21:59:54 +0200
committerGitHub <noreply@github.com>2017-09-04 21:59:54 +0200
commit6d1dab31179eb4414b45d9a94f453833ddc558ce (patch)
tree8bca1ca131e17a647a98d083087e0a42124067eb /lib/domain/libimagmail
parentf025416cf7d96b5f2a41d545c75255cab9fe2d06 (diff)
parent6583ba04a2151d940d99d4277713df4f50bf9eac (diff)
Merge pull request #1029 from matthiasbeyer/all-extensions-as-traits
All extensions as traits
Diffstat (limited to 'lib/domain/libimagmail')
-rw-r--r--lib/domain/libimagmail/src/iter.rs15
-rw-r--r--lib/domain/libimagmail/src/mail.rs17
2 files changed, 16 insertions, 16 deletions
diff --git a/lib/domain/libimagmail/src/iter.rs b/lib/domain/libimagmail/src/iter.rs
index fe1e72a4..ee418765 100644
--- a/lib/domain/libimagmail/src/iter.rs
+++ b/lib/domain/libimagmail/src/iter.rs
@@ -27,16 +27,16 @@
use mail::Mail;
use result::Result;
-use libimagentryref::reference::Ref;
+use libimagstore::store::FileLockEntry;
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 +44,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 ede27704..8f2e05c5 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> {
@@ -58,7 +60,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| {
debug!("Build reference file: {:?}", reference);
@@ -79,20 +81,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>> {
debug!("Opening Mail by Hash");
- 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> {
- debug!("Building Mail object from Ref: {:?}", r);
- 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| {
@@ -102,7 +103,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>> {