email/email/message/add/
mod.rs

1pub mod config;
2#[cfg(feature = "imap")]
3pub mod imap;
4#[cfg(feature = "maildir")]
5pub mod maildir;
6#[cfg(feature = "notmuch")]
7pub mod notmuch;
8
9use async_trait::async_trait;
10
11use crate::{
12    envelope::SingleId,
13    flag::{Flag, Flags},
14    AnyResult,
15};
16
17#[async_trait]
18pub trait AddMessage: Send + Sync {
19    /// Add the given raw email message with the given flags to the
20    /// given folder.
21    async fn add_message_with_flags(
22        &self,
23        folder: &str,
24        msg: &[u8],
25        flags: &Flags,
26    ) -> AnyResult<SingleId>;
27
28    /// Add the given raw email message with the given flag to the
29    /// given folder.
30    async fn add_message_with_flag(
31        &self,
32        folder: &str,
33        msg: &[u8],
34        flag: Flag,
35    ) -> AnyResult<SingleId> {
36        self.add_message_with_flags(folder, msg, &Flags::from_iter([flag]))
37            .await
38    }
39
40    /// Add the given raw email message to the given folder.
41    async fn add_message(&self, folder: &str, msg: &[u8]) -> AnyResult<SingleId> {
42        self.add_message_with_flags(folder, msg, &Default::default())
43            .await
44    }
45}