diff options
author | Silas Bartha <[email protected]> | 2024-05-27 14:20:08 -0400 |
---|---|---|
committer | Silas Bartha <[email protected]> | 2024-05-27 14:20:08 -0400 |
commit | ccb19be9d0e918070029f31a86c7eb546121bd87 (patch) | |
tree | 6192bc514a7ae815a8863a23b4cc59405c18ec37 /src/codec.rs | |
parent | d088553bd19c58543b908936ba8bae2bfa877b50 (diff) |
Updated docs
Diffstat (limited to 'src/codec.rs')
-rw-r--r-- | src/codec.rs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/codec.rs b/src/codec.rs index 03cdf15..8b38a9b 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -1,14 +1,26 @@ +/// Codecs enable the concealment of payload data inside the data of a carrier. pub trait Codec { + /// Data type representing the carrier. type Carrier; + + /// Data type representing the payload. type Payload; + + /// Data type representing encoder output/decoder input (usually the same as the carrier). type Output; + + /// Type of errors produced by this codec. type Error; - fn encode( - &self, - carrier: impl Into<Self::Carrier>, - payload: impl Into<Self::Payload>, - ) -> Result<Self::Output, Self::Error>; + /// Embeds payload data inside carrier, returning the result. + fn encode<C, P>(&self, carrier: C, payload: P) -> Result<Self::Output, Self::Error> + where + C: Into<Self::Carrier>, + P: Into<Self::Payload>; - fn decode(&self, encoded: impl Into<Self::Output>) -> Result<(Self::Carrier, Self::Payload), Self::Error>; + /// Extracts payload data from an encoded carrier, returning the carrier with data removed and the + /// payload data. + fn decode<E>(&self, encoded: E) -> Result<(Self::Carrier, Self::Payload), Self::Error> + where + E: Into<Self::Output>; } |