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§
Trait Implementations§
source§impl Mtp for Plain
impl Mtp for Plain
source§fn push(&mut self, buffer: &mut RingBuffer<u8>, request: &[u8]) -> Option<MsgId>
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>
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.