Skip to main content

MessageReader

Trait MessageReader 

Source
pub trait MessageReader {
    // Required method
    async fn read_msg(&mut self) -> Result<&[u8]>;
}
Expand description

This message protocol contains header and body, and the header includes checksum, datalen,respectively, u32, u32, where datalen represents the length of the body, checksum is used to check the datalen field. This is just the most basic pedestal protocol, in order to solve the sticky packet problem with TCP streams. We can build more advanced communication on top of this protocol, for example, we can use json or other forms of data representation

┌─────────────┐
│ u32 checksum│
│ u32 datalen │
└─────────────┘
┌─────────────┐
│ Body        │
│(Actual Data)│
└─────────────┘

Required Methods§

Source

async fn read_msg(&mut self) -> Result<&[u8]>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§