aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs58
1 files changed, 39 insertions, 19 deletions
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<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.