From ccb19be9d0e918070029f31a86c7eb546121bd87 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Mon, 27 May 2024 14:20:08 -0400 Subject: Updated docs --- src/codec.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/codec.rs') 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, - payload: impl Into, - ) -> Result; + /// Embeds payload data inside carrier, returning the result. + fn encode(&self, carrier: C, payload: P) -> Result + where + C: Into, + P: Into; - fn decode(&self, encoded: impl Into) -> 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(&self, encoded: E) -> Result<(Self::Carrier, Self::Payload), Self::Error> + where + E: Into; } -- cgit v1.2.3