Files
himalaya/cli/src/backends/backend.rs
T
Clément DOUIN 7c01f88006 make Backend::get_mboxes return struct instead of trait (#340)
This step was necessary to move logic from CLI to lib. Indeed, the
trait returned by get_mboxes needed to implement Table, which is
related to the CLI module only.
2022-05-29 12:36:10 +02:00

46 lines
1.5 KiB
Rust

//! Backend module.
//!
//! This module exposes the backend trait, which can be used to create
//! custom backend implementations.
use anyhow::Result;
use himalaya_lib::mbox::Mboxes;
use crate::msg::{Envelopes, Msg};
pub trait Backend<'a> {
fn connect(&mut self) -> Result<()> {
Ok(())
}
fn add_mbox(&mut self, mbox: &str) -> Result<()>;
fn get_mboxes(&mut self) -> Result<Mboxes>;
fn del_mbox(&mut self, mbox: &str) -> Result<()>;
fn get_envelopes(
&mut self,
mbox: &str,
page_size: usize,
page: usize,
) -> Result<Box<dyn Envelopes>>;
fn search_envelopes(
&mut self,
mbox: &str,
query: &str,
sort: &str,
page_size: usize,
page: usize,
) -> Result<Box<dyn Envelopes>>;
fn add_msg(&mut self, mbox: &str, msg: &[u8], flags: &str) -> Result<Box<dyn ToString>>;
fn get_msg(&mut self, mbox: &str, id: &str) -> Result<Msg>;
fn copy_msg(&mut self, mbox_src: &str, mbox_dst: &str, ids: &str) -> Result<()>;
fn move_msg(&mut self, mbox_src: &str, mbox_dst: &str, ids: &str) -> Result<()>;
fn del_msg(&mut self, mbox: &str, ids: &str) -> Result<()>;
fn add_flags(&mut self, mbox: &str, ids: &str, flags: &str) -> Result<()>;
fn set_flags(&mut self, mbox: &str, ids: &str, flags: &str) -> Result<()>;
fn del_flags(&mut self, mbox: &str, ids: &str, flags: &str) -> Result<()>;
fn disconnect(&mut self) -> Result<()> {
Ok(())
}
}