[][src]Struct grammers_mtproto::PlainMtp

#[non_exhaustive]pub struct PlainMtp;

An implementation of the Mobile Transport Protocol for plaintext (unencrypted) messages.

The reason to separate the plaintext and encrypted implementations for serializing messages is that, even though they are similar, the benefits outweight some minor code reuse.

This way, the encryption key for Mtp is mandatory so errors for trying to encrypt data without a key are completely eliminated.

Also, the plaintext part of the protocol does not need to deal with the complexity of the full protocol once encrypted messages are used, so being able to keep a simpler implementation separate is a bonus.

Implementations

impl PlainMtp[src]

pub fn new() -> Self[src]

pub fn serialize_plain_message(&mut self, body: &[u8]) -> Vec<u8>[src]

Wraps a request's data into a plain message (also known as unencrypted messages), and returns its serialized contents.

Plain messages may be used for requests that don't require an authorization key to be present, such as those needed to generate the authorization key itself.

pub fn deserialize_plain_message<'a>(
    &self,
    message: &'a [u8]
) -> Result<&'a [u8], DeserializeError>
[src]

Validates that the returned data is a correct plain message, and if it is, the method returns the inner contents of the message.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.