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/message | |
| 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 '')
| -rw-r--r-- | src/message/handshake/clientinit.rs | 10 | ||||
| -rw-r--r-- | src/message/handshake/clientinitack.rs | 20 | ||||
| -rw-r--r-- | src/message/handshake/clientinitreject.rs | 10 | ||||
| -rw-r--r-- | src/message/handshake/clientlogin.rs | 15 | ||||
| -rw-r--r-- | src/message/handshake/clientloginack.rs | 10 | ||||
| -rw-r--r-- | src/message/handshake/clientloginreject.rs | 10 | ||||
| -rw-r--r-- | src/message/handshake/connack.rs | 6 | ||||
| -rw-r--r-- | src/message/handshake/mod.rs | 5 | ||||
| -rw-r--r-- | src/message/handshake/sessioninit.rs | 10 | ||||
| -rw-r--r-- | src/message/handshake/types.rs | 25 | ||||
| -rw-r--r-- | src/message/signalproxy/heartbeat.rs | 9 | ||||
| -rw-r--r-- | src/message/signalproxy/initdata.rs | 5 | ||||
| -rw-r--r-- | src/message/signalproxy/initrequest.rs | 5 | ||||
| -rw-r--r-- | src/message/signalproxy/mod.rs | 34 | ||||
| -rw-r--r-- | src/message/signalproxy/objects/backlogmanager.rs | 11 | ||||
| -rw-r--r-- | src/message/signalproxy/rpccall.rs | 5 | ||||
| -rw-r--r-- | src/message/signalproxy/syncmessage.rs | 5 |
17 files changed, 73 insertions, 122 deletions
diff --git a/src/message/handshake/clientinit.rs b/src/message/handshake/clientinit.rs index d21d6aa..32e8595 100644 --- a/src/message/handshake/clientinit.rs +++ b/src/message/handshake/clientinit.rs @@ -1,8 +1,7 @@ +use crate::error::ProtocolError; use crate::primitive::{StringList, Variant, VariantMap}; use crate::HandshakeSerialize; -use failure::Error; - /// ClientInit is the Initial message send to the core after establishing a base layer comunication. /// /// Features @@ -44,12 +43,9 @@ pub struct ClientInit { } impl HandshakeSerialize for ClientInit { - fn serialize(&self) -> Result<Vec<u8>, Error> { + fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { let mut values: VariantMap = VariantMap::with_capacity(5); - values.insert( - "MsgType".to_string(), - Variant::String("ClientInit".to_string()), - ); + values.insert("MsgType".to_string(), Variant::String("ClientInit".to_string())); values.insert( "ClientVersion".to_string(), Variant::String(self.client_version.clone()), diff --git a/src/message/handshake/clientinitack.rs b/src/message/handshake/clientinitack.rs index a259f9c..610cdc0 100644 --- a/src/message/handshake/clientinitack.rs +++ b/src/message/handshake/clientinitack.rs @@ -1,8 +1,7 @@ +use crate::error::ProtocolError; use crate::primitive::{Variant, VariantList, VariantMap}; use crate::HandshakeSerialize; -use failure::Error; - /// ClientInitAck is received when the initialization was successfull #[derive(Debug, Clone)] pub struct ClientInitAck { @@ -21,17 +20,14 @@ pub struct ClientInitAck { } impl HandshakeSerialize for ClientInitAck { - fn serialize(&self) -> Result<Vec<u8>, Error> { + fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { let mut values: VariantMap = VariantMap::with_capacity(6); values.insert( "MsgType".to_string(), Variant::String("ClientInitAck".to_string()), ); values.insert("CoreFeatures".to_string(), Variant::u32(self.core_features)); - values.insert( - "Configured".to_string(), - Variant::bool(self.core_configured), - ); + values.insert("Configured".to_string(), Variant::bool(self.core_configured)); values.insert( "StorageBackends".to_string(), Variant::VariantList(self.storage_backends.clone()), @@ -55,15 +51,9 @@ impl From<VariantMap> for ClientInitAck { // TODO make this compatible with older clients core_features: 0, core_configured: match_variant!(input.get("Configured").unwrap(), Variant::bool), - storage_backends: match_variant!( - input.get("StorageBackends").unwrap(), - Variant::VariantList - ), + storage_backends: match_variant!(input.get("StorageBackends").unwrap(), Variant::VariantList), #[cfg(feature = "authenticators")] - authenticators: match_variant!( - input.get("Authenticators").unwrap(), - Variant::VariantList - ), + authenticators: match_variant!(input.get("Authenticators").unwrap(), Variant::VariantList), feature_list: match_variant!(input.get("FeatureList").unwrap(), Variant::StringList), } } diff --git a/src/message/handshake/clientinitreject.rs b/src/message/handshake/clientinitreject.rs index d93413d..8c2fd34 100644 --- a/src/message/handshake/clientinitreject.rs +++ b/src/message/handshake/clientinitreject.rs @@ -1,8 +1,7 @@ +use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; use crate::HandshakeSerialize; -use failure::Error; - /// ClientInitReject is received when the initialization fails #[derive(Debug, Clone)] pub struct ClientInitReject { @@ -11,16 +10,13 @@ pub struct ClientInitReject { } impl HandshakeSerialize for ClientInitReject { - fn serialize(&self) -> Result<Vec<u8>, Error> { + fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { let mut values: VariantMap = VariantMap::with_capacity(2); values.insert( "MsgType".to_string(), Variant::String("ClientInitReject".to_string()), ); - values.insert( - "ErrorString".to_string(), - Variant::String(self.error.clone()), - ); + values.insert("ErrorString".to_string(), Variant::String(self.error.clone())); return HandshakeSerialize::serialize(&values); } } diff --git a/src/message/handshake/clientlogin.rs b/src/message/handshake/clientlogin.rs index dffd996..c589810 100644 --- a/src/message/handshake/clientlogin.rs +++ b/src/message/handshake/clientlogin.rs @@ -1,8 +1,7 @@ +use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; use crate::HandshakeSerialize; -use failure::Error; - /// Login to the core with user data /// username and password are transmitted in plain text #[derive(Debug, Clone)] @@ -12,17 +11,11 @@ pub struct ClientLogin { } impl HandshakeSerialize for ClientLogin { - fn serialize(&self) -> Result<Vec<u8>, Error> { + fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { let mut values: VariantMap = VariantMap::new(); - values.insert( - "MsgType".to_string(), - Variant::String("ClientLogin".to_string()), - ); + values.insert("MsgType".to_string(), Variant::String("ClientLogin".to_string())); values.insert("User".to_string(), Variant::String(self.user.clone())); - values.insert( - "Password".to_string(), - Variant::String(self.password.clone()), - ); + values.insert("Password".to_string(), Variant::String(self.password.clone())); return HandshakeSerialize::serialize(&values); } } 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<Vec<u8>, Error> { + fn serialize(&self) -> Result<Vec<u8>, 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) } } } diff --git a/src/message/handshake/clientloginreject.rs b/src/message/handshake/clientloginreject.rs index 0c0fc85..964ce0c 100644 --- a/src/message/handshake/clientloginreject.rs +++ b/src/message/handshake/clientloginreject.rs @@ -1,8 +1,7 @@ +use crate::error::ProtocolError; use crate::primitive::{Variant, VariantMap}; use crate::HandshakeSerialize; -use failure::Error; - /// ClientLoginReject is received after the client failed to login /// It contains an error message as String #[derive(Debug, Clone)] @@ -11,16 +10,13 @@ pub struct ClientLoginReject { } impl HandshakeSerialize for ClientLoginReject { - fn serialize(&self) -> Result<Vec<u8>, Error> { + fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { let mut values: VariantMap = VariantMap::with_capacity(1); values.insert( "MsgType".to_string(), Variant::String("ClientLoginReject".to_string()), ); - values.insert( - "ErrorString".to_string(), - Variant::String(self.error.clone()), - ); + values.insert("ErrorString".to_string(), Variant::String(self.error.clone())); return HandshakeSerialize::serialize(&values); } } diff --git a/src/message/handshake/connack.rs b/src/message/handshake/connack.rs index a246679..bed0cb5 100644 --- a/src/message/handshake/connack.rs +++ b/src/message/handshake/connack.rs @@ -1,4 +1,4 @@ -use failure::Error; +use crate::error::ProtocolError; /// Data received right after initializing the connection /// @@ -30,7 +30,7 @@ impl Default for ConnAck { } impl crate::serialize::Serialize for ConnAck { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, Error> { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> { let mut bytes: Vec<u8> = Vec::new(); bytes.append(&mut self.flags.serialize()?); @@ -42,7 +42,7 @@ impl crate::serialize::Serialize for ConnAck { } impl crate::deserialize::Deserialize for ConnAck { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { + fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> { let (flen, flags) = u8::parse(b)?; let (elen, extra) = i16::parse(&b[flen..])?; let (vlen, version) = i8::parse(&b[(flen + elen)..])?; diff --git a/src/message/handshake/mod.rs b/src/message/handshake/mod.rs index 029eb86..186abf0 100644 --- a/src/message/handshake/mod.rs +++ b/src/message/handshake/mod.rs @@ -24,6 +24,7 @@ pub use protocol::*; pub use sessioninit::*; pub use types::*; +use crate::error::ProtocolError; use crate::primitive::VariantMap; use crate::{HandshakeDeserialize, HandshakeSerialize}; @@ -39,7 +40,7 @@ pub enum HandshakeMessage { } impl HandshakeSerialize for HandshakeMessage { - fn serialize(&self) -> Result<Vec<u8>, failure::Error> { + fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { match self { HandshakeMessage::ClientInit(inner) => inner.serialize(), HandshakeMessage::ClientInitAck(inner) => inner.serialize(), @@ -53,7 +54,7 @@ impl HandshakeSerialize for HandshakeMessage { } impl HandshakeDeserialize for HandshakeMessage { - fn parse(b: &[u8]) -> Result<(usize, Self), failure::Error> { + fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> { let (size, res) = VariantMap::parse(b)?; let msgtype: String = (&res["MsgType"]).into(); diff --git a/src/message/handshake/sessioninit.rs b/src/message/handshake/sessioninit.rs index 04f3cff..048324d 100644 --- a/src/message/handshake/sessioninit.rs +++ b/src/message/handshake/sessioninit.rs @@ -1,9 +1,8 @@ +use crate::error::ProtocolError; use crate::message::objects::Identity; use crate::primitive::{BufferInfo, Variant, VariantMap}; use crate::HandshakeSerialize; -use failure::Error; - /// SessionInit is received along with ClientLoginAck to initialize that user Session // TODO Replace with proper types #[derive(Debug, Clone)] @@ -46,12 +45,9 @@ impl From<VariantMap> for SessionInit { } impl HandshakeSerialize for SessionInit { - fn serialize(&self) -> Result<Vec<u8>, Error> { + fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { let mut values: VariantMap = VariantMap::with_capacity(4); - values.insert( - "MsgType".to_string(), - Variant::String("SessionInit".to_string()), - ); + values.insert("MsgType".to_string(), Variant::String("SessionInit".to_string())); // values.insert( // "Identities".to_string(), // Variant::VariantList( diff --git a/src/message/handshake/types.rs b/src/message/handshake/types.rs index 6d4960d..fd8c8fa 100644 --- a/src/message/handshake/types.rs +++ b/src/message/handshake/types.rs @@ -1,8 +1,6 @@ use std::result::Result; use std::vec::Vec; -use failure::Error; - use crate::error::ProtocolError; use crate::primitive::Variant; use crate::util; @@ -12,7 +10,7 @@ use crate::message::handshake::{HandshakeDeserialize, HandshakeSerialize}; use crate::primitive::VariantMap; impl HandshakeSerialize for VariantMap { - fn serialize<'a>(&'a self) -> Result<Vec<u8>, Error> { + fn serialize<'a>(&'a self) -> Result<Vec<u8>, ProtocolError> { let mut res: Vec<u8> = Vec::new(); for (k, v) in self { @@ -29,7 +27,7 @@ impl HandshakeSerialize for VariantMap { } impl HandshakeDeserialize for VariantMap { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { + fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> { let (_, len) = i32::parse(&b[0..4])?; let mut pos: usize = 4; @@ -45,7 +43,7 @@ impl HandshakeDeserialize for VariantMap { match name { Variant::String(x) => map.insert(x, value), Variant::ByteArray(x) => map.insert(x, value), - _ => bail!(ProtocolError::WrongVariant), + _ => return Err(ProtocolError::WrongVariant), }; } @@ -58,21 +56,18 @@ pub fn serialize_variantmap() { let mut test_variantmap = VariantMap::new(); test_variantmap.insert("Configured".to_string(), Variant::bool(true)); let bytes = [ - 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, - 117, 0, 114, 0, 101, 0, 100, 0, 0, 0, 1, 0, 1, + 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, 117, 0, + 114, 0, 101, 0, 100, 0, 0, 0, 1, 0, 1, ] .to_vec(); - assert_eq!( - HandshakeSerialize::serialize(&test_variantmap).unwrap(), - bytes - ); + assert_eq!(HandshakeSerialize::serialize(&test_variantmap).unwrap(), bytes); } #[test] pub fn deserialize_variantmap() { let test_bytes: &[u8] = &[ - 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, - 117, 0, 114, 0, 101, 0, 100, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, 117, 0, + 114, 0, 101, 0, 100, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, ]; let mut test_variantmap = VariantMap::new(); test_variantmap.insert("Configured".to_string(), Variant::bool(true)); @@ -86,8 +81,8 @@ pub fn deserialize_variantmap() { #[test] pub fn deserialize_variantmap_utf8() { let test_bytes: &[u8] = &[ - 0, 0, 0, 2, 0, 0, 0, 12, 0, 0, 0, 0, 10, 67, 111, 110, 102, 105, 103, 117, 114, 101, 100, - 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 2, 0, 0, 0, 12, 0, 0, 0, 0, 10, 67, 111, 110, 102, 105, 103, 117, 114, 101, 100, 0, 0, 0, 1, + 0, 1, 0, 0, 0, 1, ]; let mut test_variantmap = VariantMap::new(); test_variantmap.insert("Configured".to_string(), Variant::bool(true)); diff --git a/src/message/signalproxy/heartbeat.rs b/src/message/signalproxy/heartbeat.rs index 58dc430..32df3d4 100644 --- a/src/message/signalproxy/heartbeat.rs +++ b/src/message/signalproxy/heartbeat.rs @@ -1,3 +1,4 @@ +use crate::error::ProtocolError; use crate::message::MessageType; use crate::primitive::{DateTime, Variant, VariantList}; use crate::{deserialize::Deserialize, serialize::Serialize}; @@ -8,7 +9,7 @@ pub struct HeartBeat { } impl Serialize for HeartBeat { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> { let mut res = VariantList::new(); res.push(Variant::i32(MessageType::HeartBeat as i32)); @@ -19,7 +20,7 @@ impl Serialize for HeartBeat { } impl Deserialize for HeartBeat { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> { let (size, mut res) = VariantList::parse(&b)?; res.remove(0); @@ -39,7 +40,7 @@ pub struct HeartBeatReply { } impl Serialize for HeartBeatReply { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> { let mut res = VariantList::new(); res.push(Variant::i32(MessageType::HeartBeatReply as i32)); @@ -50,7 +51,7 @@ impl Serialize for HeartBeatReply { } impl Deserialize for HeartBeatReply { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> { let (size, mut res) = VariantList::parse(&b)?; res.remove(0); diff --git a/src/message/signalproxy/initdata.rs b/src/message/signalproxy/initdata.rs index a391b4a..2b9fa18 100644 --- a/src/message/signalproxy/initdata.rs +++ b/src/message/signalproxy/initdata.rs @@ -1,3 +1,4 @@ +use crate::error::ProtocolError; use crate::message::MessageType; use crate::primitive::{Variant, VariantList}; use crate::{deserialize::Deserialize, serialize::Serialize}; @@ -12,7 +13,7 @@ pub struct InitData { } impl Serialize for InitData { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> { let mut res = VariantList::new(); res.push(Variant::i32(MessageType::InitData as i32)); @@ -26,7 +27,7 @@ impl Serialize for InitData { } impl Deserialize for InitData { - fn parse(b: &[u8]) -> Result<(usize, Self), failure::Error> { + fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> { let (size, mut res) = VariantList::parse(&b)?; res.remove(0); diff --git a/src/message/signalproxy/initrequest.rs b/src/message/signalproxy/initrequest.rs index 1beef5c..79b6cbc 100644 --- a/src/message/signalproxy/initrequest.rs +++ b/src/message/signalproxy/initrequest.rs @@ -1,3 +1,4 @@ +use crate::error::ProtocolError; use crate::message::MessageType; use crate::primitive::{Variant, VariantList}; use crate::{deserialize::Deserialize, serialize::Serialize}; @@ -9,7 +10,7 @@ pub struct InitRequest { } impl Serialize for InitRequest { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> { let mut res = VariantList::new(); res.push(Variant::i32(MessageType::InitRequest as i32)); @@ -21,7 +22,7 @@ impl Serialize for InitRequest { } impl Deserialize for InitRequest { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> { let (size, mut res) = VariantList::parse(&b)?; res.remove(0); diff --git a/src/message/signalproxy/mod.rs b/src/message/signalproxy/mod.rs index cc1fc54..5801846 100644 --- a/src/message/signalproxy/mod.rs +++ b/src/message/signalproxy/mod.rs @@ -1,5 +1,6 @@ use crate::{ deserialize::Deserialize, + error::ProtocolError, primitive::{Variant, VariantList}, serialize::Serialize, }; @@ -57,13 +58,7 @@ impl SyncProxy { } /// Send a SyncMessage - fn sync( - &self, - class_name: Class, - object_name: Option<&str>, - function: &str, - params: VariantList, - ) { + fn sync(&self, class_name: Class, object_name: Option<&str>, function: &str, params: VariantList) { let msg = SyncMessage { class_name, object_name: object_name.unwrap_or("").to_string(), @@ -91,12 +86,10 @@ pub trait Syncable { /// Send a SyncMessage. fn send_sync(&self, function: &str, params: VariantList) { - crate::message::signalproxy::SYNC_PROXY.get().unwrap().sync( - Self::CLASS, - None, - function, - params, - ); + crate::message::signalproxy::SYNC_PROXY + .get() + .unwrap() + .sync(Self::CLASS, None, function, params); } /// Send a RpcCall @@ -125,10 +118,9 @@ where Self: Sized, { match msg.slot_name.as_str() { - "requestUpdate" => StatefulSyncableServer::request_update( - self, - msg.params.pop().unwrap().try_into().unwrap(), - ), + "requestUpdate" => { + StatefulSyncableServer::request_update(self, msg.params.pop().unwrap().try_into().unwrap()) + } _ => StatefulSyncableServer::sync_custom(self, msg), } } @@ -167,9 +159,7 @@ pub trait StatefulSyncableClient: Syncable + translation::NetworkMap { Self: Sized, { match msg.slot_name.as_str() { - "update" => { - StatefulSyncableClient::update(self, msg.params.pop().unwrap().try_into().unwrap()) - } + "update" => StatefulSyncableClient::update(self, msg.params.pop().unwrap().try_into().unwrap()), _ => StatefulSyncableClient::sync_custom(self, msg), } } @@ -229,7 +219,7 @@ pub enum Message { // } impl Serialize for Message { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> { match &self { Message::SyncMessage(value) => value.serialize(), Message::RpcCall(value) => value.serialize(), @@ -242,7 +232,7 @@ impl Serialize for Message { } impl Deserialize for Message { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> { let (_, message_type) = i32::parse(&b[9..13])?; match MessageType::from(message_type) { diff --git a/src/message/signalproxy/objects/backlogmanager.rs b/src/message/signalproxy/objects/backlogmanager.rs index 7d6624d..4e74b15 100644 --- a/src/message/signalproxy/objects/backlogmanager.rs +++ b/src/message/signalproxy/objects/backlogmanager.rs @@ -48,6 +48,8 @@ // receiveBacklogAllFiltered(first: MsgId, last: MsgId, limit: Int, additional: Int, type: Int, flags: Int, messages: QVariantList) // } +#![allow(non_snake_case, dead_code)] + use crate::primitive::VariantList; /// Receive and Request Backlog @@ -59,14 +61,7 @@ impl BacklogManager { /// Loads backlog for `bufferId`, starting at message `first`, up to `last` /// (plus `additional` more messages after `last`) but at most `limit` /// messages total. - fn requestBacklog( - self: Self, - buffer_id: u32, - first: u32, - last: u32, - limit: u32, - additional: u32, - ) { + fn requestBacklog(self: Self, buffer_id: u32, first: u32, last: u32, limit: u32, additional: u32) { unimplemented!() } diff --git a/src/message/signalproxy/rpccall.rs b/src/message/signalproxy/rpccall.rs index e485f6b..04c75cb 100644 --- a/src/message/signalproxy/rpccall.rs +++ b/src/message/signalproxy/rpccall.rs @@ -1,3 +1,4 @@ +use crate::error::ProtocolError; use crate::message::MessageType; use crate::primitive::Message; use crate::primitive::{Variant, VariantList}; @@ -21,7 +22,7 @@ pub struct DisplayMessage { // } impl Serialize for RpcCall { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> { let mut res = VariantList::new(); res.push(Variant::i32(MessageType::RpcCall as i32)); @@ -39,7 +40,7 @@ impl Serialize for RpcCall { } impl Deserialize for RpcCall { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> { let (size, mut res) = VariantList::parse(&b)?; res.remove(0); diff --git a/src/message/signalproxy/syncmessage.rs b/src/message/signalproxy/syncmessage.rs index 7e7aabc..d1f359b 100644 --- a/src/message/signalproxy/syncmessage.rs +++ b/src/message/signalproxy/syncmessage.rs @@ -1,3 +1,4 @@ +use crate::error::ProtocolError; use crate::message::MessageType; use crate::primitive::{Variant, VariantList}; use crate::{deserialize::Deserialize, serialize::Serialize}; @@ -85,7 +86,7 @@ pub struct SyncMessage { // impl Act for SyncMessage {} impl Serialize for SyncMessage { - fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> { + fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> { let mut res = VariantList::new(); res.push(Variant::i32(MessageType::SyncMessage as i32)); @@ -100,7 +101,7 @@ impl Serialize for SyncMessage { } impl Deserialize for SyncMessage { - fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error> { + fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> { let (size, mut res) = VariantList::parse(&b)?; res.remove(0); |
