diff options
| author | Max Audron <audron@cocaine.farm> | 2021-04-05 18:03:46 +0200 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2021-04-05 18:03:46 +0200 |
| commit | d7488b8040278c2cf9cd1b1eead206efe408cd9f (patch) | |
| tree | 1188190a730e6c0d4277c588545c5ff557afb3cd /src/lib.rs | |
| parent | WIP: impl signalproxy types (diff) | |
WIP: impl more signalproxy objects
Diffstat (limited to '')
| -rw-r--r-- | src/lib.rs | 58 |
1 files changed, 39 insertions, 19 deletions
@@ -1,3 +1,4 @@ +#![feature(test)] #![feature(external_doc)] #![feature(doc_cfg)] #![doc(include = "../README.md")] @@ -26,32 +27,51 @@ pub mod error; /// Framing impl to be used with [`tokio_util::codec::Framed`] pub mod frame; -use failure::Error; +/// Traits for Serialization of objects +pub mod serialize { + use failure::Error; -/// Serialization of types and structs to the quassel byteprotocol -pub trait Serialize { - fn serialize(&self) -> Result<Vec<u8>, Error>; -} + /// Serialization of types and structs to the quassel byteprotocol + pub trait Serialize { + fn serialize(&self) -> Result<Vec<u8>, Error>; + } -/// Serialization of UTF-8 based Strings to the quassel byteprotocol -pub trait SerializeUTF8 { - fn serialize_utf8(&self) -> Result<Vec<u8>, Error>; -} + /// Serialization of UTF-8 based Strings to the quassel byteprotocol + pub trait SerializeUTF8 { + fn serialize_utf8(&self) -> Result<Vec<u8>, Error>; + } -/// Deserialization of types and structs to the quassel byteprotocol -pub trait Deserialize { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> - where - Self: std::marker::Sized; + pub trait SerializeVariant { + fn serialize_variant(&self) -> Result<Vec<u8>, Error>; + } } -/// Deserialization of UTF-8 based Strings to the quassel byteprotocol -pub trait DeserializeUTF8 { - fn parse_utf8(b: &[u8]) -> Result<(usize, Self), Error> - where - Self: std::marker::Sized; +/// Traits for parsing objects +pub mod deserialize { + use failure::Error; + + /// Deserialization of types and structs to the quassel byteprotocol + pub trait Deserialize { + fn parse(b: &[u8]) -> Result<(usize, Self), Error> + 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), Error> + where + Self: std::marker::Sized; + } + + pub trait DeserializeVariant { + fn parse_variant(b: &[u8]) -> Result<(usize, Self), Error> + where + Self: std::marker::Sized; + } } +use failure::Error; /// HandshakeSerialize implements the serialization needed during the handhake phase. /// /// The protocol has some minor differences during this phase compared to the regular parsing. |
