summaryrefslogtreecommitdiff
path: root/src/codec.rs
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <[email protected]>2024-05-27 11:18:36 -0400
committerLibravatar Silas Bartha <[email protected]>2024-05-27 11:18:36 -0400
commit16d1838e5bca2e90ca7cf8584a786b84fc409708 (patch)
treecf24077cd48b1c9fd1119fd7b7097a32660071e5 /src/codec.rs
Initial Commit
Diffstat (limited to 'src/codec.rs')
-rw-r--r--src/codec.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/codec.rs b/src/codec.rs
new file mode 100644
index 0000000..03cdf15
--- /dev/null
+++ b/src/codec.rs
@@ -0,0 +1,14 @@
+pub trait Codec {
+ type Carrier;
+ type Payload;
+ type Output;
+ type Error;
+
+ fn encode(
+ &self,
+ carrier: impl Into<Self::Carrier>,
+ payload: impl Into<Self::Payload>,
+ ) -> Result<Self::Output, Self::Error>;
+
+ fn decode(&self, encoded: impl Into<Self::Output>) -> Result<(Self::Carrier, Self::Payload), Self::Error>;
+}