aboutsummaryrefslogtreecommitdiff
path: root/src/message/signalproxy
diff options
context:
space:
mode:
Diffstat (limited to 'src/message/signalproxy')
-rw-r--r--src/message/signalproxy/initrequest.rs2
-rw-r--r--src/message/signalproxy/mod.rs35
-rw-r--r--src/message/signalproxy/objects/aliasmanager.rs3
-rw-r--r--src/message/signalproxy/objects/buffersyncer.rs7
-rw-r--r--src/message/signalproxy/objects/bufferviewconfig.rs12
-rw-r--r--src/message/signalproxy/objects/bufferviewmanager.rs6
-rw-r--r--src/message/signalproxy/objects/certmanager.rs5
-rw-r--r--src/message/signalproxy/objects/coreinfo.rs9
-rw-r--r--src/message/signalproxy/objects/highlightrulemanager.rs18
-rw-r--r--src/message/signalproxy/objects/identity.rs3
-rw-r--r--src/message/signalproxy/objects/ignorelistmanager.rs48
-rw-r--r--src/message/signalproxy/objects/ircchannel.rs8
-rw-r--r--src/message/signalproxy/objects/ircuser.rs3
-rw-r--r--src/message/signalproxy/objects/network.rs20
-rw-r--r--src/message/signalproxy/objects/networkconfig.rs6
-rw-r--r--src/message/signalproxy/rpccall/client.rs5
-rw-r--r--src/message/signalproxy/syncmessage.rs1
17 files changed, 122 insertions, 69 deletions
diff --git a/src/message/signalproxy/initrequest.rs b/src/message/signalproxy/initrequest.rs
index ad6a3f2..1aea1c9 100644
--- a/src/message/signalproxy/initrequest.rs
+++ b/src/message/signalproxy/initrequest.rs
@@ -35,5 +35,3 @@ impl Deserialize for InitRequest {
))
}
}
-
-
diff --git a/src/message/signalproxy/mod.rs b/src/message/signalproxy/mod.rs
index 90cf7e5..7e36017 100644
--- a/src/message/signalproxy/mod.rs
+++ b/src/message/signalproxy/mod.rs
@@ -114,26 +114,30 @@ pub trait StatefulSyncableServer: Syncable + translation::NetworkMap
where
Variant: From<<Self as translation::NetworkMap>::Item>,
{
- fn sync(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
match msg.slot_name.as_str() {
"requestUpdate" => {
- StatefulSyncableServer::request_update(self, msg.params.pop().unwrap().try_into().unwrap())
+ StatefulSyncableServer::request_update(
+ self,
+ msg.params.pop().ok_or(ProtocolError::WrongVariant)?.try_into()?,
+ )?;
+ Ok(())
}
_ => StatefulSyncableServer::sync_custom(self, msg),
}
}
#[allow(unused_mut)]
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
#[allow(clippy::match_single_binding)]
match msg.slot_name.as_str() {
- _ => (),
+ _ => Ok(()),
}
}
@@ -146,43 +150,54 @@ where
}
/// Server -> Client: Update the whole object with received data
- fn request_update(&mut self, mut param: <Self as translation::NetworkMap>::Item)
+ fn request_update(
+ &mut self,
+ mut param: <Self as translation::NetworkMap>::Item,
+ ) -> Result<(), ProtocolError>
where
Self: Sized,
{
*self = Self::from_network_map(&mut param);
+ Ok(())
}
}
/// Methods for a Stateful Syncable object on the server side.
pub trait StatefulSyncableClient: Syncable + translation::NetworkMap {
- fn sync(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
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().ok_or(ProtocolError::WrongVariant)?.try_into()?,
+ )?;
+ Ok(())
+ }
_ => StatefulSyncableClient::sync_custom(self, msg),
}
}
#[allow(unused_mut)]
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
#[allow(clippy::match_single_binding)]
match msg.slot_name.as_str() {
- _ => (),
+ _ => Ok(()),
}
}
/// Client -> Server: Update the whole object with received data
- fn update(&mut self, mut param: <Self as translation::NetworkMap>::Item)
+ fn update(&mut self, mut param: <Self as translation::NetworkMap>::Item) -> Result<(), ProtocolError>
where
Self: Sized,
{
*self = Self::from_network_map(&mut param);
+ Ok(())
}
/// Server -> Client: Update the whole object with received data
diff --git a/src/message/signalproxy/objects/aliasmanager.rs b/src/message/signalproxy/objects/aliasmanager.rs
index 02add49..7b98426 100644
--- a/src/message/signalproxy/objects/aliasmanager.rs
+++ b/src/message/signalproxy/objects/aliasmanager.rs
@@ -40,7 +40,7 @@ impl StatefulSyncableClient for AliasManager {}
#[cfg(feature = "server")]
impl StatefulSyncableServer for AliasManager {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -50,6 +50,7 @@ impl StatefulSyncableServer for AliasManager {
)),
_ => (),
}
+ Ok(())
}
}
diff --git a/src/message/signalproxy/objects/buffersyncer.rs b/src/message/signalproxy/objects/buffersyncer.rs
index b2e12c4..22a435d 100644
--- a/src/message/signalproxy/objects/buffersyncer.rs
+++ b/src/message/signalproxy/objects/buffersyncer.rs
@@ -1,6 +1,7 @@
use std::collections::HashMap;
use crate::{
+ error::ProtocolError,
message::{Class, Syncable},
primitive::{BufferId, MessageType, MsgId},
};
@@ -135,7 +136,7 @@ impl BufferSyncer {
#[cfg(feature = "client")]
impl crate::message::StatefulSyncableClient for BufferSyncer {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
@@ -153,12 +154,13 @@ impl crate::message::StatefulSyncableClient for BufferSyncer {
"setMarkerLine" => self.set_marker_line(get_param!(msg), get_param!(msg)),
_ => (),
}
+ Ok(())
}
}
#[cfg(feature = "server")]
impl crate::message::StatefulSyncableServer for BufferSyncer {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
@@ -174,6 +176,7 @@ impl crate::message::StatefulSyncableServer for BufferSyncer {
"requestSetMarkerLine" => self.set_marker_line(get_param!(msg), get_param!(msg)),
_ => (),
}
+ Ok(())
}
}
diff --git a/src/message/signalproxy/objects/bufferviewconfig.rs b/src/message/signalproxy/objects/bufferviewconfig.rs
index 286e83a..ade5bc5 100644
--- a/src/message/signalproxy/objects/bufferviewconfig.rs
+++ b/src/message/signalproxy/objects/bufferviewconfig.rs
@@ -15,7 +15,11 @@ pub struct BufferViewConfig {
pub buffers: Vec<BufferId>,
#[network(rename = "RemovedBuffers", network = "list", variant = "VariantList")]
pub removed_buffers: Vec<BufferId>,
- #[network(rename = "TemporarilyRemovedBuffers", network = "list", variant = "VariantList")]
+ #[network(
+ rename = "TemporarilyRemovedBuffers",
+ network = "list",
+ variant = "VariantList"
+ )]
pub temporarily_removed_buffers: Vec<BufferId>,
#[network(rename = "bufferViewId", default, skip)]
@@ -124,7 +128,7 @@ impl BufferViewConfig {
#[cfg(feature = "client")]
impl StatefulSyncableClient for BufferViewConfig {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -144,12 +148,13 @@ impl StatefulSyncableClient for BufferViewConfig {
}
_ => (),
}
+ Ok(())
}
}
#[cfg(feature = "server")]
impl StatefulSyncableServer for BufferViewConfig {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -182,6 +187,7 @@ impl StatefulSyncableServer for BufferViewConfig {
"setSortAlphabetically" => self.sort_alphabetically = msg.params.remove(0).try_into().unwrap(),
_ => (),
}
+ Ok(())
}
}
diff --git a/src/message/signalproxy/objects/bufferviewmanager.rs b/src/message/signalproxy/objects/bufferviewmanager.rs
index 1097ade..6d2d593 100644
--- a/src/message/signalproxy/objects/bufferviewmanager.rs
+++ b/src/message/signalproxy/objects/bufferviewmanager.rs
@@ -80,7 +80,7 @@ impl BufferViewManager {
#[cfg(feature = "client")]
impl StatefulSyncableClient for BufferViewManager {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -93,12 +93,13 @@ impl StatefulSyncableClient for BufferViewManager {
}
_ => (),
}
+ Ok(())
}
}
#[cfg(feature = "server")]
impl StatefulSyncableServer for BufferViewManager {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -124,6 +125,7 @@ impl StatefulSyncableServer for BufferViewManager {
}
_ => (),
}
+ Ok(())
}
}
diff --git a/src/message/signalproxy/objects/certmanager.rs b/src/message/signalproxy/objects/certmanager.rs
index a518b7b..ab78500 100644
--- a/src/message/signalproxy/objects/certmanager.rs
+++ b/src/message/signalproxy/objects/certmanager.rs
@@ -1,6 +1,6 @@
use libquassel_derive::{NetworkList, NetworkMap};
-use crate::message::{Syncable, Class};
+use crate::message::{Class, Syncable};
#[allow(unused_imports)]
use crate::primitive::Variant;
@@ -30,7 +30,7 @@ impl CertManager {
#[cfg(feature = "client")]
impl crate::message::StatefulSyncableClient for CertManager {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -39,6 +39,7 @@ impl crate::message::StatefulSyncableClient for CertManager {
"setSslKey" => self.set_ssl_key(get_param!(msg)),
_ => (),
}
+ Ok(())
}
}
diff --git a/src/message/signalproxy/objects/coreinfo.rs b/src/message/signalproxy/objects/coreinfo.rs
index 5036abd..8dba602 100644
--- a/src/message/signalproxy/objects/coreinfo.rs
+++ b/src/message/signalproxy/objects/coreinfo.rs
@@ -22,7 +22,7 @@ impl CoreInfo {
#[cfg(feature = "client")]
impl crate::message::StatefulSyncableClient for CoreInfo {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -31,6 +31,7 @@ impl crate::message::StatefulSyncableClient for CoreInfo {
"setCoreData" => self.set_core_data(CoreData::from_network_map(&mut get_param!(msg))),
_ => (),
}
+ Ok(())
}
/// Not Implemented
@@ -44,10 +45,14 @@ impl crate::message::StatefulSyncableClient for CoreInfo {
#[cfg(feature = "server")]
impl crate::message::StatefulSyncableServer for CoreInfo {
/// Not Implemented
- fn request_update(&mut self, mut _param: <CoreInfo as NetworkMap>::Item)
+ fn request_update(
+ &mut self,
+ mut _param: <CoreInfo as NetworkMap>::Item,
+ ) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
+ Ok(())
}
}
diff --git a/src/message/signalproxy/objects/highlightrulemanager.rs b/src/message/signalproxy/objects/highlightrulemanager.rs
index 7accb17..9af0b4c 100644
--- a/src/message/signalproxy/objects/highlightrulemanager.rs
+++ b/src/message/signalproxy/objects/highlightrulemanager.rs
@@ -1,5 +1,6 @@
use libquassel_derive::{sync, NetworkList, NetworkMap};
+use crate::error::ProtocolError;
use crate::message::Class;
#[allow(unused_imports)]
@@ -135,7 +136,7 @@ impl HighlightRuleManager {
#[cfg(feature = "client")]
impl StatefulSyncableClient for HighlightRuleManager {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
@@ -156,12 +157,13 @@ impl StatefulSyncableClient for HighlightRuleManager {
"setNicksCaseSensitive" => self.set_nicks_case_sensitive(get_param!(msg)),
_ => (),
}
+ Ok(())
}
}
#[cfg(feature = "server")]
impl StatefulSyncableServer for HighlightRuleManager {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
@@ -182,6 +184,7 @@ impl StatefulSyncableServer for HighlightRuleManager {
"requestSetNicksCaseSensitive" => self.set_nicks_case_sensitive(get_param!(msg)),
_ => (),
}
+ Ok(())
}
}
@@ -223,11 +226,12 @@ impl From<HighlightNickType> for Variant {
}
}
-// TODO error handling
-impl From<Variant> for HighlightNickType {
- fn from(value: Variant) -> Self {
- #[allow(clippy::unnecessary_fallible_conversions)]
- HighlightNickType::try_from(value).unwrap()
+impl TryFrom<Variant> for HighlightNickType {
+ type Error = ProtocolError;
+
+ fn try_from(value: Variant) -> Result<Self, Self::Error> {
+ let i: i32 = value.try_into()?;
+ Self::try_from(i).map_err(|_| ProtocolError::WrongVariant)
}
}
diff --git a/src/message/signalproxy/objects/identity.rs b/src/message/signalproxy/objects/identity.rs
index ec7d9b4..e745a9e 100644
--- a/src/message/signalproxy/objects/identity.rs
+++ b/src/message/signalproxy/objects/identity.rs
@@ -96,7 +96,7 @@ impl Identity {
#[cfg(feature = "client")]
impl StatefulSyncableClient for Identity {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -123,6 +123,7 @@ impl StatefulSyncableClient for Identity {
"setRealName" => self.set_real_name(get_param!(msg)),
_ => (),
}
+ Ok(())
}
}
diff --git a/src/message/signalproxy/objects/ignorelistmanager.rs b/src/message/signalproxy/objects/ignorelistmanager.rs
index b97ca77..4697611 100644
--- a/src/message/signalproxy/objects/ignorelistmanager.rs
+++ b/src/message/signalproxy/objects/ignorelistmanager.rs
@@ -1,4 +1,5 @@
use crate::{
+ error::ProtocolError,
message::{Class, Syncable},
primitive::Variant,
};
@@ -118,7 +119,7 @@ impl IgnoreListManager {
#[cfg(feature = "client")]
impl crate::message::StatefulSyncableClient for IgnoreListManager {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
@@ -142,12 +143,13 @@ impl crate::message::StatefulSyncableClient for IgnoreListManager {
}
_ => (),
}
+ Ok(())
}
}
#[cfg(feature = "server")]
impl crate::message::StatefulSyncableServer for IgnoreListManager {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
@@ -171,6 +173,7 @@ impl crate::message::StatefulSyncableServer for IgnoreListManager {
}
_ => (),
}
+ Ok(())
}
}
@@ -201,8 +204,6 @@ pub struct IgnoreListItem {
//////////////////////////////////////
-use num_traits::{FromPrimitive, ToPrimitive};
-
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, FromPrimitive, ToPrimitive)]
pub enum IgnoreType {
@@ -213,19 +214,22 @@ pub enum IgnoreType {
impl From<IgnoreType> for Variant {
fn from(value: IgnoreType) -> Self {
- Variant::i32(value.to_i32().unwrap())
+ Variant::i32(value as i32)
}
}
-impl From<Variant> for IgnoreType {
- fn from(value: Variant) -> Self {
- IgnoreType::from_i32(value.try_into().unwrap()).unwrap()
+impl TryFrom<Variant> for IgnoreType {
+ type Error = ProtocolError;
+
+ fn try_from(value: Variant) -> Result<Self, Self::Error> {
+ let i: i32 = value.try_into()?;
+ Self::try_from(i).map_err(|_| ProtocolError::WrongVariant)
}
}
impl From<IgnoreType> for i32 {
fn from(value: IgnoreType) -> Self {
- value.to_i32().unwrap()
+ value as i32
}
}
@@ -252,19 +256,22 @@ pub enum StrictnessType {
impl From<StrictnessType> for Variant {
fn from(value: StrictnessType) -> Self {
- Variant::i32(value.to_i32().unwrap())
+ Variant::i32(value as i32)
}
}
-impl From<Variant> for StrictnessType {
- fn from(value: Variant) -> Self {
- StrictnessType::from_i32(value.try_into().unwrap()).unwrap()
+impl TryFrom<Variant> for StrictnessType {
+ type Error = ProtocolError;
+
+ fn try_from(value: Variant) -> Result<Self, Self::Error> {
+ let i: i32 = value.try_into()?;
+ Self::try_from(i).map_err(|_| ProtocolError::WrongVariant)
}
}
impl From<StrictnessType> for i32 {
fn from(value: StrictnessType) -> Self {
- value.to_i32().unwrap()
+ value as i32
}
}
@@ -291,19 +298,22 @@ pub enum ScopeType {
impl From<ScopeType> for Variant {
fn from(value: ScopeType) -> Self {
- Variant::i32(value.to_i32().unwrap())
+ Variant::i32(value as i32)
}
}
-impl From<Variant> for ScopeType {
- fn from(value: Variant) -> Self {
- ScopeType::from_i32(value.try_into().unwrap()).unwrap()
+impl TryFrom<Variant> for ScopeType {
+ type Error = ProtocolError;
+
+ fn try_from(value: Variant) -> Result<Self, Self::Error> {
+ let i: i32 = value.try_into()?;
+ Self::try_from(i).map_err(|_| ProtocolError::WrongVariant)
}
}
impl From<ScopeType> for i32 {
fn from(value: ScopeType) -> Self {
- value.to_i32().unwrap()
+ value as i32
}
}
diff --git a/src/message/signalproxy/objects/ircchannel.rs b/src/message/signalproxy/objects/ircchannel.rs
index 9648210..ef42d3b 100644
--- a/src/message/signalproxy/objects/ircchannel.rs
+++ b/src/message/signalproxy/objects/ircchannel.rs
@@ -172,7 +172,7 @@ impl IrcChannel {
#[cfg(feature = "client")]
impl crate::message::StatefulSyncableClient for IrcChannel {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -195,6 +195,7 @@ impl crate::message::StatefulSyncableClient for IrcChannel {
"setUserModes" => self.set_user_modes(get_param!(msg), get_param!(msg)),
_ => (),
}
+ Ok(())
}
/// Not Implemented for this type
@@ -209,7 +210,10 @@ impl crate::message::StatefulSyncableClient for IrcChannel {
#[cfg(feature = "server")]
impl crate::message::StatefulSyncableServer for IrcChannel {
/// Not Implemented for this type
- fn request_update(&mut self, _param: <IrcChannel as crate::message::NetworkMap>::Item)
+ fn request_update(
+ &mut self,
+ _param: <IrcChannel as crate::message::NetworkMap>::Item,
+ ) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
diff --git a/src/message/signalproxy/objects/ircuser.rs b/src/message/signalproxy/objects/ircuser.rs
index 3b807ed..8529405 100644
--- a/src/message/signalproxy/objects/ircuser.rs
+++ b/src/message/signalproxy/objects/ircuser.rs
@@ -111,7 +111,7 @@ impl IrcUser {
#[cfg(feature = "client")]
impl crate::message::StatefulSyncableClient for IrcUser {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -142,6 +142,7 @@ impl crate::message::StatefulSyncableClient for IrcUser {
"updateHostmask" => self.update_hostmask(get_param!(msg)),
_ => unimplemented!(),
}
+ Ok(())
}
}
diff --git a/src/message/signalproxy/objects/network.rs b/src/message/signalproxy/objects/network.rs
index 3d2ee8b..d256f67 100644
--- a/src/message/signalproxy/objects/network.rs
+++ b/src/message/signalproxy/objects/network.rs
@@ -192,7 +192,7 @@ impl Syncable for Network {
#[cfg(feature = "client")]
impl crate::message::StatefulSyncableClient for Network {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
@@ -223,9 +223,10 @@ impl crate::message::StatefulSyncableClient for Network {
"setMessageRateDelay" => self.network_info.set_msg_rate_message_delay(get_param!(msg)),
"setMyNick" => self.set_my_nick(get_param!(msg)),
"setNetworkName" => self.network_info.set_network_name(get_param!(msg)),
- "setNetworkInfo" => self.set_network_info(NetworkInfo::from_network_map(
- &mut VariantMap::try_from(msg.params.remove(0)).unwrap(),
- )),
+ "setNetworkInfo" => {
+ let mut map = VariantMap::try_from(msg.params.remove(0))?;
+ self.set_network_info(NetworkInfo::from_network_map(&mut map));
+ }
"setPerform" => self.network_info.set_perform(get_param!(msg)),
"setRejoinChannels" => self.network_info.set_rejoin_channels(get_param!(msg)),
"setSaslAccount" => self.network_info.set_sasl_account(get_param!(msg)),
@@ -254,23 +255,26 @@ impl crate::message::StatefulSyncableClient for Network {
"setUseSasl" => self.network_info.set_use_sasl(get_param!(msg)),
_ => (),
}
+ Ok(())
}
}
#[cfg(feature = "server")]
impl crate::message::StatefulSyncableServer for Network {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), ProtocolError>
where
Self: Sized,
{
match msg.slot_name.as_str() {
"requestConnect" => self.connect(),
"requestDisconnect" => self.disconnect(),
- "requestSetNetworkInfo" => self.set_network_info(NetworkInfo::from_network_map(
- &mut VariantMap::try_from(msg.params.remove(0)).unwrap(),
- )),
+ "requestSetNetworkInfo" => {
+ let mut map = VariantMap::try_from(msg.params.remove(0))?;
+ self.set_network_info(NetworkInfo::from_network_map(&mut map));
+ }
_ => (),
}
+ Ok(())
}
}
diff --git a/src/message/signalproxy/objects/networkconfig.rs b/src/message/signalproxy/objects/networkconfig.rs
index c4f5397..6268a69 100644
--- a/src/message/signalproxy/objects/networkconfig.rs
+++ b/src/message/signalproxy/objects/networkconfig.rs
@@ -28,7 +28,7 @@ impl Syncable for NetworkConfig {
#[cfg(feature = "client")]
impl crate::message::StatefulSyncableClient for NetworkConfig {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -43,12 +43,13 @@ impl crate::message::StatefulSyncableClient for NetworkConfig {
"setStandardCtcp" => self.set_standard_ctcp(get_param!(msg)),
_ => (),
}
+ Ok(())
}
}
#[cfg(feature = "server")]
impl crate::message::StatefulSyncableServer for NetworkConfig {
- fn sync_custom(&mut self, mut msg: crate::message::SyncMessage)
+ fn sync_custom(&mut self, mut msg: crate::message::SyncMessage) -> Result<(), crate::error::ProtocolError>
where
Self: Sized,
{
@@ -63,5 +64,6 @@ impl crate::message::StatefulSyncableServer for NetworkConfig {
"requestSetStandardCtcp" => self.set_standard_ctcp(get_param!(msg)),
_ => (),
}
+ Ok(())
}
}
diff --git a/src/message/signalproxy/rpccall/client.rs b/src/message/signalproxy/rpccall/client.rs
index 13653b9..bf35cb5 100644
--- a/src/message/signalproxy/rpccall/client.rs
+++ b/src/message/signalproxy/rpccall/client.rs
@@ -13,10 +13,7 @@ impl RpcCallType for KickClient {
const DIRECTION: Direction = Direction::ClientToServer;
fn to_network(&self) -> Result<Vec<crate::primitive::Variant>, crate::ProtocolError> {
- Ok(vec![
- Variant::ByteArray(Self::NAME.to_string()),
- self.id.into(),
- ])
+ Ok(vec![Variant::ByteArray(Self::NAME.to_string()), self.id.into()])
}
fn from_network(
diff --git a/src/message/signalproxy/syncmessage.rs b/src/message/signalproxy/syncmessage.rs
index d38ea20..5a7163b 100644
--- a/src/message/signalproxy/syncmessage.rs
+++ b/src/message/signalproxy/syncmessage.rs
@@ -122,4 +122,3 @@ impl Deserialize for SyncMessage {
))
}
}
-