Skip to main content

MessageBoxes

Struct MessageBoxes 

Source
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

Source

pub fn new() -> Self

Create a new, empty MessageBoxes (no prior state).

Source

pub fn load(state: UpdatesStateSnap) -> Self

Create a MessageBoxes from a previously-persisted snapshot.

Source

pub fn is_empty(&self) -> bool

Whether this box has any state yet.

Source

pub fn set_state(&mut self, state: State)

Set state right after login (must only call when Self::is_empty is true).

Source

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.

Source

pub fn session_state(&self) -> UpdatesStateSnap

Current snapshot suitable for session persistence.

Source

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.

Source

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.

Source

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

Source

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

Source

pub fn apply_difference(&mut self, difference: Difference) -> UpdateAndPeers

Apply the result of a GetDifference RPC call.

Source§

impl MessageBoxes

Source

pub fn apply_channel_difference( &mut self, difference: ChannelDifference, ) -> UpdateAndPeers

Apply the result of a GetChannelDifference RPC call.

Source

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.

Source

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.

Source

pub fn end_channel_difference(&mut self, reason: PrematureEndReason)

Trait Implementations§

Source§

impl Debug for MessageBoxes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MessageBoxes

Source§

fn default() -> Self

Returns the “default value” for a type. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more