MessageBoxes

Struct MessageBoxes 

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

Contains all live message boxes and is able to process incoming updates for each of them.

See https://core.telegram.org/api/updates#message-related-event-sequences.

Implementations§

Source§

impl MessageBoxes

Creation, querying, and setting base state.

Source

pub fn new() -> MessageBoxes

Create a new, empty MessageBoxes.

Source

pub fn load(state: UpdatesState) -> MessageBoxes

Create a MessageBoxes from a previously known update state.

Source

pub fn session_state(&self) -> UpdatesState

Return the current state in a format that sessions understand.

This should be used for persisting the state.

Source

pub fn is_empty(&self) -> bool

Return true if the message box is empty and has no state yet.

Source

pub fn check_deadlines(&mut self) -> Instant

Return the next deadline when receiving updates should timeout.

If a deadline expired, the corresponding entries will be marked as needing to get its difference. While there are entries pending of getting their difference, this method returns the current instant.

Source

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

Sets the update state.

Should be called right after login if MessageBoxes::new was used, otherwise undesirable updates will be fetched.

Should only be called while MessageBoxes::is_empty.

Source

pub fn try_set_channel_state(&mut self, id: i64, pts: i32)

Like MessageBoxes::set_state, but for channels. Useful when getting dialogs.

The update state will only be updated if no entry was known previously.

Source§

impl MessageBoxes

Source

pub fn process_updates( &mut self, updates: UpdatesLike, ) -> Result<(Vec<(Update, State)>, Vec<User>, Vec<Chat>), Gap>

Process an update and return what should be done with it.

Updates corresponding to entries for which their difference is currently being fetched will be ignored. While according to the updates’ documentation:

Implementations [have] to postpone updates received via the socket while filling gaps in the event and Update sequences, as well as avoid filling gaps in the same sequence.

In practice, these updates should have also been retrieved through getting difference.

Source§

impl MessageBoxes

Getting and applying account difference.

Source

pub fn get_difference(&self) -> Option<GetDifference>

Return the request that needs to be made to get the difference, if any.

Source

pub fn apply_difference( &mut self, difference: Difference, ) -> (Vec<(Update, State)>, Vec<User>, Vec<Chat>)

Similar to MessageBoxes::process_updates, but using the result from getting difference.

Source§

impl MessageBoxes

Getting and applying channel difference.

Source

pub fn get_channel_difference(&self) -> Option<GetChannelDifference>

Return the request that needs to be made to get a channel’s difference, if any.

Note that this only returns the skeleton of a request. Both the channel hash and limit will be their default value.

Source

pub fn apply_channel_difference( &mut self, difference: ChannelDifference, ) -> (Vec<(Update, State)>, Vec<User>, Vec<Chat>)

Similar to MessageBoxes::process_updates, but using the result from getting difference.

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<(), Error>

Formats the value using the given formatter. 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, 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> 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 = 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.