Browse Source

melib: add supports_search() method to MailBackend

async
Manos Pitsidianakis 2 years ago
parent
commit
32f196143e
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 1
      melib/src/backends.rs
  2. 5
      melib/src/backends/imap.rs
  3. 4
      melib/src/backends/jmap.rs
  4. 4
      melib/src/backends/maildir/backend.rs
  5. 4
      melib/src/backends/mbox.rs
  6. 4
      melib/src/backends/notmuch.rs
  7. 5
      src/plugins/backend.rs

1
melib/src/backends.rs

@ -287,6 +287,7 @@ pub type ResultFuture<T> = Result<Pin<Box<dyn Future<Output = Result<T>> + Send
pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
fn is_async(&self) -> bool;
fn is_remote(&self) -> bool;
fn supports_search(&self) -> bool;
fn is_online(&self) -> Result<()> {
Err(MeliError::new("Unimplemented."))
}

5
melib/src/backends/imap.rs

@ -183,6 +183,11 @@ impl MailBackend for ImapType {
fn is_remote(&self) -> bool {
true
}
fn supports_search(&self) -> bool {
true
}
fn get_async(
&mut self,
mailbox: &Mailbox,

4
melib/src/backends/jmap.rs

@ -198,6 +198,10 @@ impl MailBackend for JmapType {
true
}
fn supports_search(&self) -> bool {
true
}
fn is_online(&self) -> Result<()> {
if self.online.lock().unwrap().1.is_err()
&& Instant::now().duration_since(self.online.lock().unwrap().0)

4
melib/src/backends/maildir/backend.rs

@ -183,6 +183,10 @@ impl MailBackend for MaildirType {
false
}
fn supports_search(&self) -> bool {
false
}
fn is_online(&self) -> Result<()> {
Ok(())
}

4
melib/src/backends/mbox.rs

@ -710,6 +710,10 @@ impl MailBackend for MboxType {
false
}
fn supports_search(&self) -> bool {
false
}
fn is_online(&self) -> Result<()> {
Ok(())
}

4
melib/src/backends/notmuch.rs

@ -326,6 +326,10 @@ impl MailBackend for NotmuchDb {
false
}
fn supports_search(&self) -> bool {
true
}
fn is_online(&self) -> Result<()> {
Ok(())
}

5
src/plugins/backend.rs

@ -75,6 +75,11 @@ impl MailBackend for PluginBackend {
false
}
fn supports_search(&self) -> bool {
// TODO
false
}
fn is_online(&self) -> Result<()> {
if let Ok(mut is_online) = self.is_online.try_lock() {
let now = std::time::Instant::now();

Loading…
Cancel
Save