Skip to main content

SecretChatState

Struct SecretChatState 

Source
pub struct SecretChatState {
Show 17 fields pub id: i32, pub access_hash: i64, pub auth_key: [u8; 256], pub admin: bool, pub user_id: i64, pub in_seq_no: i32, pub out_seq_no: i32, pub in_seq_no_x: i32, pub out_seq_no_x: i32, pub layer: i32, pub ttl: i32, pub ttr: i32, pub updated_at_secs: u64, pub mtproto: u8, pub rekeying_state: RekeyingState, pub temp_rekey_map: HashMap<i64, Vec<u8>>, pub sent: VecDeque<(i32, Vec<u8>)>,
}
Expand description

Per-chat state stored in memory (and optionally persisted to disk).

Fields§

§id: i32

Secret chat id assigned by Telegram.

§access_hash: i64

Access hash for InputEncryptedChat.

§auth_key: [u8; 256]

Shared 256-byte key from the DH exchange. Written unencrypted to the store file.

§admin: bool

true = we initiated this chat (User A).

§user_id: i64

Peer user ID.

§in_seq_no: i32

Raw incoming sequence counter.

§out_seq_no: i32

Raw outgoing sequence counter.

§in_seq_no_x: i32

Parity bit for incoming wire encoding.

§out_seq_no_x: i32

Parity bit for outgoing wire encoding.

§layer: i32

Remote peer’s supported layer (updated on NotifyLayer receipt).

§ttl: i32

Per-message TTL in seconds (0 = no TTL).

§ttr: i32

Messages until next re-key.

§updated_at_secs: u64

Unix epoch seconds of last auth_key rotation (for 7-day re-key timer).

§mtproto: u8

MTProto version in use (1 or 2).

§rekeying_state: RekeyingState

Where the current re-key exchange stands.

§temp_rekey_map: HashMap<i64, Vec<u8>>

Keyed by exchange_id. Requested state: stores 256-byte private key. Accepted state: stores 256-byte computed auth_key.

§sent: VecDeque<(i32, Vec<u8>)>

Ring buffer of (wire_out_seq_no, encrypted_blob) for Resend support. Not persisted: only valid for the current session.

Implementations§

Source§

impl SecretChatState

Source

pub fn new( id: i32, access_hash: i64, auth_key: [u8; 256], admin: bool, user_id: i64, ) -> Self

Create the state for a freshly established chat.

admin is true on the initiating side; it decides the sequence-number parity bits. The layer defaults to crate::dh::DEFAULT_LAYER until the peer announces its own.

Source

pub fn wire_in_seq_no(&self) -> i32

Wire-encoded incoming seq no: raw * 2 + x.

Source

pub fn wire_out_seq_no(&self) -> i32

Wire-encoded outgoing seq no: raw * 2 + x.

Source

pub fn secs_since_update(&self) -> u64

Seconds since last auth_key rotation.

Source

pub fn rotate_key(&mut self, new_key: [u8; 256])

Stamp updated_at_secs to now, reset ttr, swap in the new key.

Source

pub fn push_sent(&mut self, wire_seq_no: i32, blob: Vec<u8>)

Buffer an outgoing encrypted blob for potential Resend. wire_seq_no is the wire_out_seq_no that was used when this blob was sent.

Source

pub fn lookup_sent(&self, start_wire: i32, end_wire: i32) -> Vec<(i32, Vec<u8>)>

Look up sent blobs in the range [start_wire, end_wire] (inclusive, step 2).

Trait Implementations§

Source§

impl Clone for SecretChatState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SecretChatState

Source§

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

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> 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> 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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