melib: add as_any() method to MailBackend trait
Cast the trait object into an &Any object. Then we can downcast it to its actual type with downcast_ref().sql
parent
8ba9500de6
commit
f56b89dde3
|
@ -36,6 +36,7 @@ use self::maildir::MaildirType;
|
|||
#[cfg(feature = "mbox_backend")]
|
||||
use self::mbox::MboxType;
|
||||
use super::email::{Envelope, EnvelopeHash, Flag};
|
||||
use std::any::Any;
|
||||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
use std::ops::Deref;
|
||||
|
@ -191,6 +192,8 @@ pub trait MailBackend: ::std::fmt::Debug + Send + Sync {
|
|||
fn folder_operation(&mut self, _path: &str, _op: FolderOperation) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
}
|
||||
|
||||
/// A `BackendOp` manages common operations for the various mail backends. They only live for the
|
||||
|
|
|
@ -358,6 +358,10 @@ impl MailBackend for ImapType {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn::std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! get_conf_val {
|
||||
|
|
|
@ -552,6 +552,10 @@ impl MailBackend for MaildirType {
|
|||
folder
|
||||
)))
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn::std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl MaildirType {
|
||||
|
|
|
@ -548,6 +548,10 @@ impl MailBackend for MboxType {
|
|||
fn save(&self, _bytes: &[u8], _folder: &str, _flags: Option<Flag>) -> Result<()> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn::std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl MboxType {
|
||||
|
|
Loading…
Reference in New Issue