Skip to main content

InMemoryStore

Struct InMemoryStore 

Source
pub struct InMemoryStore { /* private fields */ }
Expand description

In-memory MailStore backed by Vecs under an RwLock.

Build via Self::new + the chainable with_* setters. See the module docs for an example.

Implementations§

Source§

impl InMemoryStore

Source

pub fn new() -> Self

Construct an empty store.

Source

pub fn with_mailbox(self, id: i64, name: &str) -> Self

Append a mailbox with the given id and name.

Source

pub fn with_message(self, msg: Message) -> Self

Append a pre-built Message. Use make_message for a sane default shape and mutate before passing in if you need overrides.

Source

pub fn with_message_raw(self, msg_id: i64, raw: Vec<u8>) -> Self

Map a message id to raw RFC 5322 bytes. MailStore::read_message_raw returns these bytes; without this setter that method returns None.

Source

pub fn with_parsed_body(self, raw: Vec<u8>, parsed: ParsedBody) -> Self

Map a specific raw byte sequence to a parsed body. The store’s MailStore::parse_message returns the override when called with matching bytes, and ParsedBody::default() otherwise.

Source

pub fn with_mailbox_counts(self, mb_id: i64, counts: MailboxCounts) -> Self

Override mailbox counts for a specific mailbox id. Without this the store derives total/unread from the message list.

Source

pub fn list_mailboxes_fails(self, msg: &str) -> Self

Make MailStore::list_mailboxes return an error carrying msg.

Source

pub fn mailbox_status_fails(self, msg: &str) -> Self

Make MailStore::mailbox_status return an error carrying msg.

Source

pub fn list_messages_fails(self, msg: &str) -> Self

Make MailStore::list_messages return an error carrying msg.

Source

pub fn get_message_fails(self, msg: &str) -> Self

Make MailStore::get_message_by_db_id return an error carrying msg.

Source

pub fn list_thread_messages_fails(self, msg: &str) -> Self

Make MailStore::list_thread_messages return an error carrying msg.

Source

pub fn update_flags_fails(self, msg: &str) -> Self

Make MailStore::update_flags return an error carrying msg.

Source

pub fn add_flags_fails(self, msg: &str) -> Self

Make MailStore::add_flags return an error carrying msg.

Source

pub fn submission_fails_with(self, msg: &str) -> Self

Configure MailStore::submit_message to fail with a description.

Source

pub fn submission_fails_silently(self) -> Self

Configure MailStore::submit_message to fail without a description.

Source

pub fn flags_for(&self, mailbox_id: i64, uid: u32) -> Option<u32>

Read back the current flag bitmask for (mailbox_id, uid). None when the row is missing. Tests use this to assert the effect of Email/set updates and destroys.

Trait Implementations§

Source§

impl Default for InMemoryStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl MailStore for InMemoryStore

Source§

fn list_mailboxes<'life0, 'life1, 'async_trait>( &'life0 self, _user: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Mailbox>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all mailboxes for user. Used by Mailbox/get and Mailbox/query.
Source§

fn mailbox_status<'life0, 'async_trait>( &'life0 self, mailbox_id: i64, ) -> Pin<Box<dyn Future<Output = Result<MailboxCounts, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return (total, unread) for a mailbox. May be best-effort: handlers fall back to (0, 0) on error.
Source§

fn list_messages<'life0, 'async_trait>( &'life0 self, mailbox_id: i64, offset: u32, limit: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List up to limit messages in mailbox_id starting at offset, ordered however the store deems natural (typically by uid).
Source§

fn get_message_by_db_id<'life0, 'life1, 'async_trait>( &'life0 self, user: &'life1 str, id: i64, ) -> Pin<Box<dyn Future<Output = Result<Option<Message>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Look up a message by its database/primary id. Returns Ok(None) when the id exists but doesn’t belong to user, or when no such id exists.
Source§

fn list_thread_messages<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user: &'life1 str, thread_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

All messages in thread_id for user, ordered chronologically.
Source§

fn update_flags<'life0, 'async_trait>( &'life0 self, mailbox_id: i64, uid: u32, flags: u32, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Replace a message’s flag bitmask. mailbox_id + uid identify the row.
Source§

fn add_flags<'life0, 'async_trait>( &'life0 self, mailbox_id: i64, uid: u32, flags: u32, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

OR flags into the message’s flag bitmask. Used to set \Deleted.
Source§

fn read_message_raw<'life0, 'life1, 'async_trait>( &'life0 self, message: &'life1 Message, ) -> Pin<Box<dyn Future<Output = Option<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read the raw RFC 5322 bytes for a message. Returns None when not available (e.g. blob missing on disk). Used to populate bodyValues, textBody, htmlBody, and the submission path.
Source§

fn parse_message(&self, raw: &[u8]) -> ParsedBody

Parse raw bytes into text/html body plus attachment metadata. Pulled out of Self::read_message_raw so the same bytes can serve both Email/get rendering and EmailSubmission/set outbound delivery.
Source§

fn submit_message<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _user: &'life1 str, _message: &'life2 Message, _raw: &'life3 [u8], ) -> Pin<Box<dyn Future<Output = SubmissionResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Submit a previously-stored email through the outbound queue. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.