From d7488b8040278c2cf9cd1b1eead206efe408cd9f Mon Sep 17 00:00:00 2001 From: Max Audron Date: Mon, 5 Apr 2021 18:03:46 +0200 Subject: WIP: impl more signalproxy objects --- src/lib.rs | 58 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index a2a3a25..e2f57c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, Error>; -} + /// Serialization of types and structs to the quassel byteprotocol + pub trait Serialize { + fn serialize(&self) -> Result, Error>; + } -/// Serialization of UTF-8 based Strings to the quassel byteprotocol -pub trait SerializeUTF8 { - fn serialize_utf8(&self) -> Result, Error>; -} + /// Serialization of UTF-8 based Strings to the quassel byteprotocol + pub trait SerializeUTF8 { + fn serialize_utf8(&self) -> Result, 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, 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. -- cgit v1.2.3