pub struct MessageBoxes { /* private fields */ }Expand description
All live message boxes. The single authority for update-gap detection.
See https://core.telegram.org/api/updates#message-related-event-sequences.
Implementations§
Source§impl MessageBoxes
impl MessageBoxes
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, empty MessageBoxes (no prior state).
Sourcepub fn load(state: UpdatesStateSnap) -> Self
pub fn load(state: UpdatesStateSnap) -> Self
Create a MessageBoxes from a previously-persisted snapshot.
Sourcepub fn set_state(&mut self, state: State)
pub fn set_state(&mut self, state: State)
Set state right after login (must only call when Self::is_empty is true).
Sourcepub fn try_set_channel_state(&mut self, id: i64, pts: i32)
pub fn try_set_channel_state(&mut self, id: i64, pts: i32)
Record channel pts from GetDialogs - does nothing if the channel is already tracked.
Sourcepub fn session_state(&self) -> UpdatesStateSnap
pub fn session_state(&self) -> UpdatesStateSnap
Current snapshot suitable for session persistence.
Sourcepub fn check_deadlines(&mut self) -> Instant
pub fn check_deadlines(&mut self) -> Instant
Return the next deadline instant.
Call this in the select! loop to know when to wake up and check for
expired gaps or timeouts. When entries need diff, returns now so the
caller immediately runs the diff.
Sourcepub fn get_difference(&self) -> Option<GetDifference>
pub fn get_difference(&self) -> Option<GetDifference>
Return the GetDifference request to execute, if any.
The caller is responsible for executing the RPC and calling
Self::apply_difference with the result.
Sourcepub fn get_channel_difference(&mut self) -> Option<(i64, GetChannelDifference)>
pub fn get_channel_difference(&mut self) -> Option<(i64, GetChannelDifference)>
Return the skeleton of a GetChannelDifference request, if any channel needs it.
The caller must fill in access_hash and limit before executing.
Call Self::apply_channel_difference or Self::end_channel_difference with the result.
Source§impl MessageBoxes
impl MessageBoxes
Sourcepub fn process_updates(
&mut self,
updates: UpdatesLike,
) -> Result<UpdateAndPeers, Gap>
pub fn process_updates( &mut self, updates: UpdatesLike, ) -> Result<UpdateAndPeers, Gap>
Process an update batch. Returns Ok((updates, users, chats)) or
Err(Gap) when a gap has been detected and get_difference must be called.
This is the single entry point for all incoming updates.
Source§impl MessageBoxes
impl MessageBoxes
Sourcepub fn apply_difference(&mut self, difference: Difference) -> UpdateAndPeers
pub fn apply_difference(&mut self, difference: Difference) -> UpdateAndPeers
Apply the result of a GetDifference RPC call.
Source§impl MessageBoxes
impl MessageBoxes
Sourcepub fn apply_channel_difference(
&mut self,
difference: ChannelDifference,
) -> UpdateAndPeers
pub fn apply_channel_difference( &mut self, difference: ChannelDifference, ) -> UpdateAndPeers
Apply the result of a GetChannelDifference RPC call.
Sourcepub fn abort_difference(&mut self)
pub fn abort_difference(&mut self)
Mark a channel diff as ended prematurely (access error or ban). Abort a pending global difference after a parse or RPC failure.
Clears Key::Common and Key::Secondary from getting_diff_for so
that check_deadlines() stops returning Instant::now() and the
deadline arm stops spawning hundreds of no-op tasks while the previous
attempt’s backoff sleep is still running.
The pts counters are left unchanged; the next real update gap will re-queue getDifference automatically.
Sourcepub fn force_reset_common_pts(
&mut self,
pts: i32,
qts: i32,
date: i32,
seq: i32,
)
pub fn force_reset_common_pts( &mut self, pts: i32, qts: i32, date: i32, seq: i32, )
Forcibly advance Common + Secondary pts to the server-reported values.
Called after a getDifference parse failure (unknown TL constructor from a newer Telegram layer) so the stale pts gap does not re-trigger getDifference in an infinite loop. Channel entries are left unchanged.