kafka_protocol/compression/
none.rs

1use crate::protocol::buf::{ByteBuf, ByteBufMut};
2use anyhow::Result;
3
4use super::{Compressor, Decompressor};
5
6/// Noop compression implementation.
7pub struct None;
8
9impl<B: ByteBufMut> Compressor<B> for None {
10    type BufMut = B;
11    fn compress<R, F>(buf: &mut B, f: F) -> Result<R>
12    where
13        F: FnOnce(&mut Self::BufMut) -> Result<R>,
14    {
15        f(buf)
16    }
17}
18
19impl<B: ByteBuf> Decompressor<B> for None {
20    type Buf = B;
21    fn decompress<R, F>(buf: &mut B, f: F) -> Result<R>
22    where
23        F: FnOnce(&mut Self::Buf) -> Result<R>,
24    {
25        f(buf)
26    }
27}