Skip to main content

MailRelayStore

Struct MailRelayStore 

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

Framework-neutral in-memory relay model, NOT a hosted or durable service. All outputs are owned copies. Save/restore snapshots atomically in a real service; enforce admission limits and serialized access outside this model. The short-lived Identity nonce cache is not part of the snapshot.

Implementations§

Source§

impl MailRelayStore

Source

pub fn new(origin: impl Into<String>) -> Result<Self>

Source

pub fn with_limits( origin: impl Into<String>, max_packets: usize, max_bytes: usize, ) -> Result<Self>

Per-mailbox limits on retained packets.

Source

pub fn origin(&self) -> &str

Source

pub fn discovery(&self) -> Value

Source

pub fn publish( &mut self, value: &Value, now: i64, ) -> Result<AcceptedRecord<MailboxCardPayload>>

Source

pub fn publish_with_nonce_store<S: NonceStore + ?Sized>( &mut self, value: &Value, now: i64, nonces: &mut S, ) -> Result<AcceptedRecord<MailboxCardPayload>>

Inject the origin-wide Identity nonce store when several protocols share a service. All other checks precede nonce consumption.

Source

pub fn card( &self, mailbox_id: &str, ) -> Result<AcceptedRecord<MailboxCardPayload>>

Source

pub fn deliver( &mut self, mailbox_id: &str, packet: &Packet, now: i64, ) -> Result<DeliveryResult>

Packets are asynchronous signed objects: no live-write window or nonce maximum applies.

Source

pub fn set_sender_blocked( &mut self, mailbox: &str, sender: AgentId, blocked: bool, ) -> Result<()>

Owner sender policy for new packets. Mail defines no management endpoint: the host authenticates the mailbox owner before calling this.

Source

pub fn list( &self, mailbox: &str, jwt: &str, now: i64, limit: usize, cursor: Option<&str>, ) -> Result<ListResponse<PacketRecord>>

The cursor is the decimal seq of the last returned record.

Source

pub fn delete( &mut self, mailbox: &str, id: &str, jwt: &str, now: i64, ) -> Result<()>

Source

pub fn prune(&mut self, now: i64) -> Result<()>

Drop expired packets and tombstones, then forget mailboxes whose current card’s receive_until passed; a later card is a new registration.

Source

pub fn snapshot(&self) -> Result<Value>

Source

pub fn from_snapshot( value: &Value, max_packets: usize, max_bytes: usize, ) -> Result<Self>

Restore trusted local state saved by snapshot; limits are not part of it.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.