use async_trait::async_trait;
use crate::types::{
FlagOp, Inserted, InsertMessage, Mailbox, MailboxStatus, Message, QueryFilter,
};
pub type StoreError = Box<dyn std::error::Error + Send + Sync>;
#[async_trait]
pub trait MailboxStore: Send + Sync {
async fn create_mailbox(&self, user: &str, name: &str) -> Result<Mailbox, StoreError>;
async fn delete_mailbox(&self, user: &str, name: &str) -> Result<bool, StoreError>;
async fn rename_mailbox(&self, user: &str, from: &str, to: &str) -> Result<(), StoreError>;
async fn list_mailboxes(&self, user: &str) -> Result<Vec<Mailbox>, StoreError>;
async fn get_mailbox(&self, user: &str, name: &str) -> Result<Option<Mailbox>, StoreError>;
async fn get_mailbox_by_id(&self, id: i64) -> Result<Option<Mailbox>, StoreError>;
async fn mailbox_status(&self, mailbox_id: i64) -> Result<MailboxStatus, StoreError>;
async fn insert_message(&self, input: InsertMessage<'_>) -> Result<Inserted, StoreError>;
async fn get_message_by_uid(
&self,
mailbox_id: i64,
uid: u32,
) -> Result<Option<Message>, StoreError>;
async fn get_message(&self, id: i64) -> Result<Option<Message>, StoreError>;
async fn find_by_message_id(
&self,
user: &str,
message_id: &str,
) -> Result<Option<Message>, StoreError>;
async fn copy_message(
&self,
src_mailbox: i64,
uid: u32,
dst_mailbox: i64,
) -> Result<u32, StoreError>;
async fn move_message(
&self,
src_mailbox: i64,
uid: u32,
dst_mailbox: i64,
) -> Result<u32, StoreError>;
async fn expunge(&self, mailbox_id: i64) -> Result<Vec<u32>, StoreError>;
async fn set_flags(&self, mailbox_id: i64, uid: u32, flags: u32) -> Result<u64, StoreError>;
async fn add_flags(&self, mailbox_id: i64, uid: u32, flags: u32) -> Result<u64, StoreError>;
async fn remove_flags(&self, mailbox_id: i64, uid: u32, flags: u32) -> Result<u64, StoreError>;
async fn store_flags_if_unchanged(
&self,
mailbox_id: i64,
uid: u32,
op: FlagOp,
flags: u32,
unchangedsince: u64,
) -> Result<Option<u64>, StoreError>;
async fn thread_id_for_message(
&self,
user: &str,
message_id: &str,
) -> Result<Option<String>, StoreError>;
async fn thread_message_ids(
&self,
user: &str,
thread_id: &str,
) -> Result<Vec<i64>, StoreError>;
async fn thread_references(&self, message_id: i64) -> Result<Vec<i64>, StoreError>;
async fn messages_changed_since(
&self,
mailbox_id: i64,
modseq: u64,
) -> Result<Vec<Message>, StoreError>;
async fn query_messages(&self, filter: QueryFilter<'_>) -> Result<Vec<Message>, StoreError>;
async fn user_storage_bytes(&self, user: &str) -> Result<u64, StoreError>;
}