pub struct PaddedIntermediateTransport { /* private fields */ }Expand description
MTProto Padded Intermediate transport framing.
Init tag: 0xdddddddd (4 bytes). Each message is sent as:
[4-byte LE length of (payload + random padding)][payload][0-15 random bytes]
This is the correct framing for 0xDD MTProxy secrets.
Implementations§
Source§impl PaddedIntermediateTransport
impl PaddedIntermediateTransport
Sourcepub async fn connect(addr: &str) -> Result<Self, ConnectError>
pub async fn connect(addr: &str) -> Result<Self, ConnectError>
Connect to addr and lazily send the 0xDDDDDDDD init tag on first Self::send.
Sourcepub fn from_stream(stream: TcpStream) -> Self
pub fn from_stream(stream: TcpStream) -> Self
Wrap an existing stream (the init tag will be sent on first Self::send).
Sourcepub async fn send(&mut self, data: &[u8]) -> Result<(), ConnectError>
pub async fn send(&mut self, data: &[u8]) -> Result<(), ConnectError>
Send a message with Padded Intermediate framing.
Frame layout: [total_len: u32 LE][data][random_pad: 0-15 bytes]
where total_len = data.len() + pad_len.
Sourcepub async fn recv(&mut self) -> Result<Vec<u8>, ConnectError>
pub async fn recv(&mut self) -> Result<Vec<u8>, ConnectError>
Receive the next Padded Intermediate message, stripping the random padding.
Sourcepub fn into_inner(self) -> TcpStream
pub fn into_inner(self) -> TcpStream
Discard the framing state and hand back the raw stream.
Auto Trait Implementations§
impl !Freeze for PaddedIntermediateTransport
impl RefUnwindSafe for PaddedIntermediateTransport
impl Send for PaddedIntermediateTransport
impl Sync for PaddedIntermediateTransport
impl Unpin for PaddedIntermediateTransport
impl UnsafeUnpin for PaddedIntermediateTransport
impl UnwindSafe for PaddedIntermediateTransport
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