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.
impl MessageBoxes
Creation, querying, and setting base state.
Sourcepub fn new() -> MessageBoxes
pub fn new() -> MessageBoxes
Create a new, empty MessageBoxes.
Sourcepub fn load(state: UpdatesState) -> MessageBoxes
pub fn load(state: UpdatesState) -> MessageBoxes
Create a MessageBoxes from a previously known update state.
Sourcepub fn session_state(&self) -> UpdatesState
pub fn session_state(&self) -> UpdatesState
Return the current state in a format that sessions understand.
This should be used for persisting the state.
Sourcepub fn check_deadlines(&mut self) -> Instant
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.
Sourcepub fn set_state(&mut self, state: State)
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.
Sourcepub fn try_set_channel_state(&mut self, id: i64, pts: i32)
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
impl MessageBoxes
Sourcepub fn process_updates(
&mut self,
updates: UpdatesLike,
) -> Result<(Vec<(Update, State)>, Vec<User>, Vec<Chat>), Gap>
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
Updatesequences, 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.
impl MessageBoxes
Getting and applying account difference.
Sourcepub fn get_difference(&self) -> Option<GetDifference>
pub fn get_difference(&self) -> Option<GetDifference>
Return the request that needs to be made to get the difference, if any.
Sourcepub fn apply_difference(
&mut self,
difference: Difference,
) -> (Vec<(Update, State)>, Vec<User>, Vec<Chat>)
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.
impl MessageBoxes
Getting and applying channel difference.
Sourcepub fn get_channel_difference(&self) -> Option<GetChannelDifference>
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.
Sourcepub fn apply_channel_difference(
&mut self,
difference: ChannelDifference,
) -> (Vec<(Update, State)>, Vec<User>, Vec<Chat>)
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.