ChatFacade

Struct ChatFacade 

Source
pub struct ChatFacade<P: TextProfile + Clone = DirectChannelProfile, const SLOTS: usize = 4, const PAGES: usize = 24> { /* private fields */ }
Expand description

The chat facade.

Implementations§

Source§

impl<P: TextProfile + Clone, const SLOTS: usize, const PAGES: usize> ChatFacade<P, SLOTS, PAGES>

Source

pub fn new( profile: P, local_key: PublicKey, config: EngineConfig, seeds: Seeds, ) -> Self

Source

pub fn local_key(&self) -> PublicKey

Source

pub fn session_id(&self) -> u64

The current engine session; see Seeds::session_id.

Source

pub fn channels(&self) -> &ChannelRegistry

Source

pub fn channels_mut(&mut self) -> &mut ChannelRegistry

Source

pub fn has_pending_batch(&self) -> bool

Whether a composed batch is waiting to be committed or rejected.

Source

pub fn set_local_handle(&mut self, handle: &str)

Set the Sender Handle carried on our own group messages. It survives a rebuild of the engine.

Source

pub fn local_handle(&self) -> &str

Source

pub fn member_key( &self, channel: &ChannelTag, hint: &NodeHint, ) -> Option<PublicKey>

The full key a channel member’s hint resolved to, if one has.

Source

pub fn restore(&mut self, checkpoints: &[StreamCheckpoint], now_ms: u64)

Seed outbound stream continuity from stored checkpoints, oldest first (see Engine::restore).

Source

pub fn compose( &mut self, conversation: ConversationKey, client_token: u32, intent: ComposeIntent<'_>, stored: Option<&StreamCheckpoint>, now_ms: u64, ) -> Result<PendingBatch, ChatComposeError>

Compose a message into conversation. stored is the checkpoint storage holds for it, if any, which the engine continues from when it no longer remembers the conversation itself (see Engine::recall).

Source

pub fn commit(&mut self, batch: PendingBatch) -> Result<Outbound, BatchMismatch>

Release a stored batch’s frames.

Source

pub fn reject( &mut self, batch: PendingBatch, checkpoints: &[StreamCheckpoint], seeds: Seeds, now_ms: u64, ) -> Result<Drain, BatchMismatch>

Give up on a batch that could not be stored.

Its frames are failed, and the engine is rebuilt from checkpoints— what storage holds—so nothing it composed since is remembered as sent. The channels, the resolved members, and the Sender Handle are the session’s, not the engine’s, and are kept.

The returned drain holds everything produced up to the rebuild, named by the old session. The rebuilt engine runs as seeds.session_id, which must differ from the old one: the new engine reissues handles and transmission IDs from the start.

Source

pub fn receive( &mut self, source: TextSource, payload: &[u8], now_ms: u64, ) -> Result<(), ChatReceiveError>

Feed one received text payload (without the payload-type byte).

Source

pub fn archive_result( &mut self, request_id: u32, result: ArchiveResult<'_>, now_ms: u64, )

Answer an ArchiveLookup.

Source

pub fn retransmit( &mut self, key: &ArchiveKey, handle: MessageHandle, payload: &[u8], ) -> bool

Send one of the message handle’s frames again, as the archive keeps it under key (see Engine::retransmit). Returns whether it was queued.

Source

pub fn adopt( &mut self, conversation: ConversationKey, message_id: u8, epoch: u16, stored: Option<&StreamCheckpoint>, now_ms: u64, ) -> Option<MessageHandle>

Take back one of our messages sent before this session, as the store keeps it (see Engine::adopt), with stored the conversation’s checkpoint as for ChatFacade::compose. Returns the handle it goes by now.

Source

pub fn tick(&mut self, now_ms: u64)

Advance timers: reassembly expiry, notify deadlines, repair.

Source

pub fn transmit_update( &mut self, session_id: u64, transmission_id: u32, update: TransmitUpdate, now_ms: u64, )

Report transport progress for a frame released in session_id. Reports for an earlier session are ignored.

Source

pub fn drain(&mut self) -> Drain

Everything produced since the last drain, in order.

Auto Trait Implementations§

§

impl<P, const SLOTS: usize, const PAGES: usize> Freeze for ChatFacade<P, SLOTS, PAGES>
where P: Freeze,

§

impl<P, const SLOTS: usize, const PAGES: usize> RefUnwindSafe for ChatFacade<P, SLOTS, PAGES>
where P: RefUnwindSafe,

§

impl<P, const SLOTS: usize, const PAGES: usize> Send for ChatFacade<P, SLOTS, PAGES>
where P: Send,

§

impl<P, const SLOTS: usize, const PAGES: usize> Sync for ChatFacade<P, SLOTS, PAGES>
where P: Sync,

§

impl<P, const SLOTS: usize, const PAGES: usize> Unpin for ChatFacade<P, SLOTS, PAGES>
where P: Unpin,

§

impl<P, const SLOTS: usize, const PAGES: usize> UnwindSafe for ChatFacade<P, SLOTS, PAGES>
where P: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.