diff options
Diffstat (limited to 'src/lib.rs')
| -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. |
