From b8ad94cd5061445a45d0790eee36014d34ad6817 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sat, 22 Feb 2025 22:59:01 +0100 Subject: 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. --- src/lib.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 877b31a..339b2ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, Error>; + fn serialize(&self) -> Result, ProtocolError>; } /// Serialization of UTF-8 based Strings to the quassel byteprotocol pub trait SerializeUTF8 { - fn serialize_utf8(&self) -> Result, Error>; + fn serialize_utf8(&self) -> Result, ProtocolError>; } pub trait SerializeVariant { - fn serialize_variant(&self) -> Result, Error>; + fn serialize_variant(&self) -> Result, 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, Error>; + fn serialize(&self) -> Result, 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; } -- cgit v1.2.3