Skip to main content

PtsState

Struct PtsState 

Source
pub struct PtsState {
    pub pts: i32,
    pub qts: i32,
    pub date: i32,
    pub seq: i32,
    pub channel_pts: HashMap<i64, i32>,
    pub last_update_at: Option<Instant>,
    pub getting_diff_for: HashSet<i64>,
}
Expand description

Full MTProto sequence-number state, including per-channel counters.

All fields are pub so that connect() can restore them from the persisted session without going through an artificial constructor.

Fields§

§pts: i32

Main pts counter (messages, non-channel updates).

§qts: i32

G-18: Secondary counter for secret-chat updates.

§date: i32

Date of the last received update (Unix timestamp).

§seq: i32

G-19: Combined-container sequence number.

§channel_pts: HashMap<i64, i32>

Per-channel pts counters. channel_id → pts.

§last_update_at: Option<Instant>

G-16: Timestamp of last received update for deadline-based gap detection.

§getting_diff_for: HashSet<i64>

Fix #4: Channels currently awaiting a getChannelDifference response. If a channel is in this set, no new gap-fill task is spawned for it — matches grammers’ getting_diff_for guard that prevents 1 gap → N tasks.

Implementations§

Source§

impl PtsState

Source

pub fn from_server_state(s: &State) -> Self

Source

pub fn touch(&mut self)

Record that an update was received now (resets the deadline timer).

Source

pub fn deadline_exceeded(&self) -> bool

G-16: Returns true if no update has been received for > 15 minutes.

Source

pub fn check_pts(&self, new_pts: i32, pts_count: i32) -> PtsCheckResult

Check whether new_pts is in order given pts_count new updates.

Source

pub fn check_qts(&self, new_qts: i32, qts_count: i32) -> PtsCheckResult

G-18: Check a qts value (secret chat updates).

Source

pub fn check_seq(&self, _new_seq: i32, seq_start: i32) -> PtsCheckResult

G-19: Check top-level seq for UpdatesCombined containers.

Source

pub fn check_channel_pts( &self, channel_id: i64, new_pts: i32, pts_count: i32, ) -> PtsCheckResult

Check a per-channel pts value.

Source

pub fn advance(&mut self, new_pts: i32)

Advance the global pts.

Source

pub fn advance_qts(&mut self, new_qts: i32)

Advance the qts (G-18).

Source

pub fn advance_seq(&mut self, new_seq: i32)

Advance seq (G-19).

Source

pub fn advance_channel(&mut self, channel_id: i64, new_pts: i32)

Advance a per-channel pts.

Trait Implementations§

Source§

impl Clone for PtsState

Source§

fn clone(&self) -> PtsState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PtsState

Source§

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

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

impl Default for PtsState

Source§

fn default() -> PtsState

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.