diff options
| author | Max Audron <audron@cocaine.farm> | 2025-02-26 17:53:08 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2025-02-26 17:53:08 +0100 |
| commit | 6f9c0d0f2906d05e27f9f11af6cefdf006c2cf4b (patch) | |
| tree | 3c92d681f8c98786bf7371ecfece60ed4f8d4a7c /src/deserialize.rs | |
| parent | add MsgId and BufferId to objects where needed (diff) | |
refactor variant serialization code
Factored out a lot of the serialization of variants into trait's that
have auto impl so code duplication is much reduced
Diffstat (limited to 'src/deserialize.rs')
| -rw-r--r-- | src/deserialize.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/deserialize.rs b/src/deserialize.rs new file mode 100644 index 0000000..e13f21f --- /dev/null +++ b/src/deserialize.rs @@ -0,0 +1,21 @@ +use crate::error::ProtocolError; + +/// Deserialization of types and structs to the quassel byteprotocol +pub trait Deserialize { + fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> + where + Self: std::marker::Sized; +} + +/// Deserialization of UTF-8 based Strings to the quassel byteprotocol +pub trait DeserializeUTF8 { + fn parse_utf8(b: &[u8]) -> Result<(usize, Self), ProtocolError> + where + Self: std::marker::Sized; +} + +pub trait DeserializeVariant { + fn parse_variant(b: &[u8]) -> Result<(usize, Self), ProtocolError> + where + Self: std::marker::Sized; +} |
