blob: 43a02f33f59b27dc9023ed93d5f09bfbebed148c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
mod bytes_codec;
mod length_codec;
#[cfg(feature = "ws")]
mod websocket;
pub use bytes_codec::BytesCodec;
pub use length_codec::LengthCodec;
#[cfg(feature = "ws")]
pub use websocket::{WebSocketCodec, WebSocketDecoder, WebSocketEncoder};
use crate::Result;
pub trait Codec:
Decoder<DeItem = Self::Item> + Encoder<EnItem = Self::Item> + Send + Sync + 'static + Unpin
{
type Item: Send + Sync;
}
pub trait Encoder {
type EnItem;
fn encode(&self, src: &Self::EnItem, dst: &mut [u8]) -> Result<usize>;
}
pub trait Decoder {
type DeItem;
fn decode(&self, src: &mut [u8]) -> Result<Option<(usize, Self::DeItem)>>;
}
|