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
29
30
31
32
33
34
35
use crate::protocol::buf::{ByteBuf, ByteBufMut};
use crate::protocol::{EncodeError, DecodeError};
mod none;
mod snappy;
mod gzip;
pub use none::None;
pub use snappy::Snappy;
pub use gzip::Gzip;
pub trait Compressor<B: ByteBufMut> {
type BufMut: ByteBufMut;
fn compress<R, F>(buf: &mut B, f: F) -> Result<R, EncodeError>
where
F: FnOnce(&mut Self::BufMut) -> Result<R, EncodeError>;
}
pub trait Decompressor<B: ByteBuf> {
type Buf: ByteBuf;
fn decompress<R, F>(buf: &mut B, f: F) -> Result<R, DecodeError>
where
F: FnOnce(&mut Self::Buf) -> Result<R, DecodeError>;
}