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/message/handshake/clientloginack.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/message/handshake/clientloginack.rs') diff --git a/src/message/handshake/clientloginack.rs b/src/message/handshake/clientloginack.rs index 72dd6ac..c8650f9 100644 --- a/src/message/handshake/clientloginack.rs +++ b/src/message/handshake/clientloginack.rs @@ -2,15 +2,13 @@ use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; use crate::{HandshakeDeserialize, HandshakeSerialize}; -use failure::Error; - /// ClientLoginAck is received after the client has successfully logged in /// it has no fields #[derive(Debug, Clone)] pub struct ClientLoginAck; impl HandshakeSerialize for ClientLoginAck { - fn serialize(&self) -> Result, Error> { + fn serialize(&self) -> Result, ProtocolError> { let mut values: VariantMap = VariantMap::with_capacity(1); values.insert( "MsgType".to_string(), @@ -21,15 +19,15 @@ impl HandshakeSerialize for ClientLoginAck { } impl HandshakeDeserialize for ClientLoginAck { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { + fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> { let (len, values): (usize, VariantMap) = HandshakeDeserialize::parse(b)?; let msgtype = match_variant!(&values["MsgType"], Variant::ByteArray); if msgtype == "ClientLogin" { - return Ok((len, Self {})); + Ok((len, Self {})) } else { - bail!(ProtocolError::WrongMsgType); + Err(ProtocolError::WrongMsgType) } } } -- cgit v1.2.3