djin_protocol/wire/middleware/
mod.rs

1//! A type safe `Parcel` data transformation pipeline.
2
3pub use self::pipeline::Pipeline;
4
5#[macro_use]
6pub mod pipeline;
7pub mod compression;
8pub mod rotate_bytes;
9
10use crate::Error;
11use std;
12
13/// A hook that sits between reading and writing packets.
14///
15/// Applies one transformation encoding the data, and
16/// performs the opposite transformation to decode it.
17pub trait Middleware : std::fmt::Debug
18{
19    /// Processes some data.
20    fn encode_data(&mut self, data: Vec<u8>) -> Result<Vec<u8>, Error>;
21    /// Un-processes some data.
22    fn decode_data(&mut self, data: Vec<u8>) -> Result<Vec<u8>, Error>;
23}
24