pub struct AsyncMessageCodec<S: AsyncRead + AsyncWrite + Send + Unpin> { /* private fields */ }Expand description
A codec for reading and writing length-value encoded messages.
Implementations§
Source§impl<S: AsyncRead + AsyncWrite + Send + Unpin> AsyncMessageCodec<S>
impl<S: AsyncRead + AsyncWrite + Send + Unpin> AsyncMessageCodec<S>
pub fn new(stream: S) -> Self
pub fn get_stream(&mut self) -> &mut S
Sourcepub async fn read_message(&mut self) -> Result<Bytes>
pub async fn read_message(&mut self) -> Result<Bytes>
Reads a whole length-value encoded message from the underlying reader.
Returns the message bytes as a Vec<u8>.
Sourcepub async fn write_message<T: Message>(&mut self, message: T) -> Result<()>
pub async fn write_message<T: Message>(&mut self, message: T) -> Result<()>
Writes a length-value encoded message to the underlying writer.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for AsyncMessageCodec<S>where
S: Freeze,
impl<S> RefUnwindSafe for AsyncMessageCodec<S>where
S: RefUnwindSafe,
impl<S> Send for AsyncMessageCodec<S>
impl<S> Sync for AsyncMessageCodec<S>where
S: Sync,
impl<S> Unpin for AsyncMessageCodec<S>
impl<S> UnsafeUnpin for AsyncMessageCodec<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for AsyncMessageCodec<S>where
S: UnwindSafe,
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