summaryrefslogtreecommitdiffstats
path: root/melib/src/backends.rs
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-06-28 19:16:13 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-07-06 15:12:33 +0300
commitc82367e00d6378c027ab57a14d3198667bad5b99 (patch)
tree593085b57f92364c17b937b2e75115584c828826 /melib/src/backends.rs
parent8c1fc031e598205af1d73d8ca5558a123d979f6c (diff)
BackendOp: Change set_{flag,tag} methods
Diffstat (limited to 'melib/src/backends.rs')
-rw-r--r--melib/src/backends.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/melib/src/backends.rs b/melib/src/backends.rs
index df5d56b2..4fe74859 100644
--- a/melib/src/backends.rs
+++ b/melib/src/backends.rs
@@ -68,9 +68,9 @@ use std::fmt::Debug;
use std::ops::Deref;
use std::sync::{Arc, RwLock};
-use core::pin::Pin;
pub use futures::stream::Stream;
use std::future::Future;
+pub use std::pin::Pin;
use std;
use std::collections::HashMap;
@@ -330,6 +330,11 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
work_context: WorkContext,
) -> Result<std::thread::ThreadId>;
fn mailboxes(&self) -> Result<HashMap<MailboxHash, Mailbox>>;
+ fn mailboxes_async(
+ &self,
+ ) -> Result<Pin<Box<dyn Future<Output = Result<HashMap<MailboxHash, Mailbox>>> + Send>>> {
+ Err(MeliError::new("Unimplemented."))
+ }
fn operation(&self, hash: EnvelopeHash) -> Result<Box<dyn BackendOp>>;
fn save(&self, bytes: &[u8], mailbox_hash: MailboxHash, flags: Option<Flag>) -> Result<()>;
@@ -427,8 +432,16 @@ pub trait BackendOp: ::std::fmt::Debug + ::std::marker::Send {
fn description(&self) -> String;
fn as_bytes(&mut self) -> Result<&[u8]>;
fn fetch_flags(&self) -> Result<Flag>;
- fn set_flag(&mut self, envelope: &mut Envelope, flag: Flag, value: bool) -> Result<()>;
- fn set_tag(&mut self, envelope: &mut Envelope, tag: String, value: bool) -> Result<()>;
+ fn set_flag(
+ &mut self,
+ flag: Flag,
+ value: bool,
+ ) -> Result<Pin<Box<dyn Future<Output = Result<()>> + Send>>>;
+ fn set_tag(
+ &mut self,
+ tag: String,
+ value: bool,
+ ) -> Result<Pin<Box<dyn Future<Output = Result<()>> + Send>>>;
}
/// Wrapper for BackendOps that are to be set read-only.
@@ -456,10 +469,18 @@ impl BackendOp for ReadOnlyOp {
fn fetch_flags(&self) -> Result<Flag> {
self.op.fetch_flags()
}
- fn set_flag(&mut self, _envelope: &mut Envelope, _flag: Flag, _value: bool) -> Result<()> {
+ fn set_flag(
+ &mut self,
+ _flag: Flag,
+ _value: bool,
+ ) -> Result<Pin<Box<dyn Future<Output = Result<()>> + Send>>> {
Err(MeliError::new("read-only set."))
}
- fn set_tag(&mut self, _envelope: &mut Envelope, _tag: String, _value: bool) -> Result<()> {
+ fn set_tag(
+ &mut self,
+ _tag: String,
+ _value: bool,
+ ) -> Result<Pin<Box<dyn Future<Output = Result<()>> + Send>>> {
Err(MeliError::new("read-only set."))
}
}