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>
impl<P: TextProfile + Clone, const SLOTS: usize, const PAGES: usize> ChatFacade<P, SLOTS, PAGES>
pub fn new( profile: P, local_key: PublicKey, config: EngineConfig, seeds: Seeds, ) -> Self
pub fn local_key(&self) -> PublicKey
Sourcepub fn session_id(&self) -> u64
pub fn session_id(&self) -> u64
The current engine session; see Seeds::session_id.
pub fn channels(&self) -> &ChannelRegistry
pub fn channels_mut(&mut self) -> &mut ChannelRegistry
Sourcepub fn has_pending_batch(&self) -> bool
pub fn has_pending_batch(&self) -> bool
Whether a composed batch is waiting to be committed or rejected.
Sourcepub fn set_local_handle(&mut self, handle: &str)
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.
pub fn local_handle(&self) -> &str
Sourcepub fn member_key(
&self,
channel: &ChannelTag,
hint: &NodeHint,
) -> Option<PublicKey>
pub fn member_key( &self, channel: &ChannelTag, hint: &NodeHint, ) -> Option<PublicKey>
The full key a channel member’s hint resolved to, if one has.
Sourcepub fn restore(&mut self, checkpoints: &[StreamCheckpoint], now_ms: u64)
pub fn restore(&mut self, checkpoints: &[StreamCheckpoint], now_ms: u64)
Seed outbound stream continuity from stored checkpoints, oldest
first (see Engine::restore).
Sourcepub fn compose(
&mut self,
conversation: ConversationKey,
client_token: u32,
intent: ComposeIntent<'_>,
stored: Option<&StreamCheckpoint>,
now_ms: u64,
) -> Result<PendingBatch, ChatComposeError>
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).
Sourcepub fn commit(&mut self, batch: PendingBatch) -> Result<Outbound, BatchMismatch>
pub fn commit(&mut self, batch: PendingBatch) -> Result<Outbound, BatchMismatch>
Release a stored batch’s frames.
Sourcepub fn reject(
&mut self,
batch: PendingBatch,
checkpoints: &[StreamCheckpoint],
seeds: Seeds,
now_ms: u64,
) -> Result<Drain, BatchMismatch>
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.
Sourcepub fn receive(
&mut self,
source: TextSource,
payload: &[u8],
now_ms: u64,
) -> Result<(), ChatReceiveError>
pub fn receive( &mut self, source: TextSource, payload: &[u8], now_ms: u64, ) -> Result<(), ChatReceiveError>
Feed one received text payload (without the payload-type byte).
Sourcepub fn archive_result(
&mut self,
request_id: u32,
result: ArchiveResult<'_>,
now_ms: u64,
)
pub fn archive_result( &mut self, request_id: u32, result: ArchiveResult<'_>, now_ms: u64, )
Answer an ArchiveLookup.
Sourcepub fn retransmit(
&mut self,
key: &ArchiveKey,
handle: MessageHandle,
payload: &[u8],
) -> bool
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.
Sourcepub fn adopt(
&mut self,
conversation: ConversationKey,
message_id: u8,
epoch: u16,
stored: Option<&StreamCheckpoint>,
now_ms: u64,
) -> Option<MessageHandle>
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.
Sourcepub fn tick(&mut self, now_ms: u64)
pub fn tick(&mut self, now_ms: u64)
Advance timers: reassembly expiry, notify deadlines, repair.
Sourcepub fn transmit_update(
&mut self,
session_id: u64,
transmission_id: u32,
update: TransmitUpdate,
now_ms: u64,
)
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.