apalis_core/codec/
mod.rs

1use serde::{Deserialize, Serialize};
2
3use crate::error::BoxDynError;
4
5/// A codec allows backends to encode and decode data
6pub trait Codec {
7    /// The mode of storage by the codec
8    type Compact;
9    /// Error encountered by the codec
10    type Error: Into<BoxDynError>;
11    /// The encoding method
12    fn encode<I>(input: I) -> Result<Self::Compact, Self::Error>
13    where
14        I: Serialize;
15    /// The decoding method
16    fn decode<O>(input: Self::Compact) -> Result<O, Self::Error>
17    where
18        O: for<'de> Deserialize<'de>;
19}
20
21/// Encoding for tasks using json
22#[cfg(feature = "json")]
23pub mod json;