monoio_codec/
async_codec.rs

1use std::io;
2
3pub trait AsyncEncoder<Item> {
4    type Error: From<io::Error>;
5    type EncodeFuture<'a>: std::future::Future<Output = Result<(), Self::Error>>
6    where
7        Self: 'a;
8
9    fn encode<IO>(&mut self, item: Item, dst: &mut IO) -> Self::EncodeFuture<'_>;
10}
11
12pub trait AsyncDecoder {
13    type Item;
14    type Error: From<io::Error>;
15    type DecodeFuture<'a>: std::future::Future<Output = Result<Option<Self::Item>, Self::Error>>
16    where
17        Self: 'a;
18
19    fn decode<IO>(&mut self, src: &mut IO) -> Self::DecodeFuture<'_>;
20}