diff options
| author | Max Audron <audron@cocaine.farm> | 2025-02-22 22:59:01 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2025-02-22 22:59:01 +0100 |
| commit | b8ad94cd5061445a45d0790eee36014d34ad6817 (patch) | |
| tree | fb7d11e136b968d2f2b3593ba9163894baed8912 /src/lib.rs | |
| parent | update dependencies and fix errors (diff) | |
replace deprecated failure crate with thiserror
this changes the public API in that all our methods now return a proper
ProtocolError crate. Needed change anyways to properly deal with all our
errors in the long run.
Will still need to do a pass through the crate to remove all existing
unwraps where it makes sense.
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -10,9 +10,6 @@ extern crate self as libquassel; #[macro_use] mod util; -#[macro_use] -extern crate failure; - /// Quassel Structures for serialization and deserialization pub mod message; @@ -34,63 +31,64 @@ pub mod frame; #[cfg(all(feature = "client", feature = "server"))] compile_error!("feature \"client\" and feature \"server\" cannot be enabled at the same time"); +use crate::error::ProtocolError; + /// Traits for Serialization of objects pub mod serialize { - use failure::Error; + use crate::error::ProtocolError; /// Serialization of types and structs to the quassel byteprotocol pub trait Serialize { - fn serialize(&self) -> Result<Vec<u8>, Error>; + fn serialize(&self) -> Result<Vec<u8>, ProtocolError>; } /// Serialization of UTF-8 based Strings to the quassel byteprotocol pub trait SerializeUTF8 { - fn serialize_utf8(&self) -> Result<Vec<u8>, Error>; + fn serialize_utf8(&self) -> Result<Vec<u8>, ProtocolError>; } pub trait SerializeVariant { - fn serialize_variant(&self) -> Result<Vec<u8>, Error>; + fn serialize_variant(&self) -> Result<Vec<u8>, ProtocolError>; } } /// Traits for parsing objects pub mod deserialize { - use failure::Error; + use crate::error::ProtocolError; /// Deserialization of types and structs to the quassel byteprotocol pub trait Deserialize { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> + 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), Error> + 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), Error> + fn parse_variant(b: &[u8]) -> Result<(usize, Self), ProtocolError> 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. pub trait HandshakeSerialize { - fn serialize(&self) -> Result<Vec<u8>, Error>; + fn serialize(&self) -> Result<Vec<u8>, ProtocolError>; } /// HandshakeDeserialize implements the deserialization needed during the handhake phase. /// /// The protocol has some minor differences during this phase compared to the regular parsing. pub trait HandshakeDeserialize { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> + fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> where Self: std::marker::Sized; } |
