Struct grammers_mtproto::mtp::Plain

source ·
#[non_exhaustive]
pub struct Plain;
Expand description

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§

source§

impl Plain

source

pub fn new() -> Self

Trait Implementations§

source§

impl Mtp for Plain

source§

fn push(&mut self, buffer: &mut RingBuffer<u8>, request: &[u8]) -> Option<MsgId>

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.

source§

fn deserialize( &mut self, payload: &[u8] ) -> Result<Deserialization, DeserializeError>

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

source§

fn finalize(&mut self, _buffer: &mut RingBuffer<u8>)

Finalizes the buffer of requests. Read more
source§

fn reset(&mut self)

Reset the state, as if a new instance was just created.

Auto Trait Implementations§

§

impl Freeze for Plain

§

impl RefUnwindSafe for Plain

§

impl Send for Plain

§

impl Sync for Plain

§

impl Unpin for Plain

§

impl UnwindSafe for Plain

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.