selium_std/traits/compression.rs
1use anyhow::Result;
2use bytes::Bytes;
3
4/// Interface to adapt compression implementations for use with Selium.
5pub trait Compress {
6 /// Fallibly compress the `input` bytes, and output as bytes.
7 fn compress(&self, input: Bytes) -> Result<Bytes>;
8}
9
10/// Interface to adapt compression implementations for use with Selium.
11pub trait Decompress {
12 /// Fallibly decompress the `input` bytes, and output as bytes.
13 fn decompress(&self, input: Bytes) -> Result<Bytes>;
14}
15
16/// Interface for applicable compression algorithms and implementations that allow users to
17/// specify a compression level.
18pub trait CompressionLevel {
19 /// Sets the compression level to the highest possible level for the algorithm/implementation.
20 fn highest_ratio(self) -> Self;
21 /// Sets the compression level to a balance between speed and size.
22 ///
23 /// Typically set to the default compression level for the specific algorithm/implementation.
24 fn balanced(self) -> Self;
25 /// Sets the compression level to the fastest possible speed supported by the
26 /// algorithm/implementation.
27 fn fastest(self) -> Self;
28 /// Allows a user to set the compression level to a specific level.
29 fn level(self, level: u32) -> Self;
30}