pub struct Session { /* private fields */ }Expand description
Tracks per-connection MTProto session state.
A Session is cheap to create and can be reset on reconnect.
§Example
use layer_mtproto::Session;
use layer_tl_types::functions;
let mut session = Session::new();
// let msg = session.pack(&my_request);
// send(msg.to_plaintext_bytes()).await?;Implementations§
Source§impl Session
impl Session
Sourcepub fn next_msg_id(&mut self) -> MessageId
pub fn next_msg_id(&mut self) -> MessageId
Allocate a new message ID.
Sourcepub fn next_seq_no(&mut self) -> i32
pub fn next_seq_no(&mut self) -> i32
Return the next sequence number for a content-related message (RPC call).
Increments by 2 after each call so that even slots remain available for content-unrelated messages (acks, pings, etc.).
Return the next sequence number for a content-unrelated message.
Sourcepub fn pack<R: RemoteCall>(&mut self, call: &R) -> Message
pub fn pack<R: RemoteCall>(&mut self, call: &R) -> Message
Serialize an RPC function into a Message ready to send.
The message body is just the TL-serialized call; the surrounding
transport framing (auth_key_id, etc.) is applied in Message::to_plaintext_bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more