pub struct FullTransport { /* private fields */ }Expand description
MTProto Full transport framing.
Extends Intermediate with:
- 4-byte little-endian sequence number (auto-incremented per message).
- 4-byte CRC-32 at the end of each packet covering
[len][seq_no][payload].
No init byte is sent; the full format is detected by the absence of
0xef / 0xee in the first byte.
Implementations§
Source§impl FullTransport
impl FullTransport
Sourcepub async fn connect(addr: &str) -> Result<Self, ConnectError>
pub async fn connect(addr: &str) -> Result<Self, ConnectError>
Connect to addr. No init byte is sent for this transport; framing
is identified purely by the absence of the Abridged/Intermediate
init markers.
Sourcepub fn from_stream(stream: TcpStream) -> Self
pub fn from_stream(stream: TcpStream) -> Self
Wrap an existing stream. Both sequence-number counters start at 0, so this assumes the stream hasn’t already exchanged Full-framed messages.
Sourcepub async fn send(&mut self, data: &[u8]) -> Result<(), ConnectError>
pub async fn send(&mut self, data: &[u8]) -> Result<(), ConnectError>
Send a message with Full framing (length + seqno + payload + crc32).
Sourcepub async fn recv(&mut self) -> Result<Vec<u8>, ConnectError>
pub async fn recv(&mut self) -> Result<Vec<u8>, ConnectError>
Receive the next Full-framed message; validates the CRC-32.
Sourcepub fn into_inner(self) -> TcpStream
pub fn into_inner(self) -> TcpStream
Discard the framing state (including the sequence-number counters) and hand back the raw stream.
Auto Trait Implementations§
impl !Freeze for FullTransport
impl RefUnwindSafe for FullTransport
impl Send for FullTransport
impl Sync for FullTransport
impl Unpin for FullTransport
impl UnsafeUnpin for FullTransport
impl UnwindSafe for FullTransport
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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