aboutsummaryrefslogtreecommitdiff
path: root/src/message
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/message/handshake/clientinit.rs2
-rw-r--r--src/message/handshake/clientinitack.rs2
-rw-r--r--src/message/handshake/clientinitreject.rs2
-rw-r--r--src/message/handshake/clientlogin.rs2
-rw-r--r--src/message/handshake/clientloginack.rs2
-rw-r--r--src/message/handshake/connack.rs4
-rw-r--r--src/message/handshake/features.rs27
-rw-r--r--src/message/handshake/init.rs11
-rw-r--r--src/message/handshake/protocol.rs4
-rw-r--r--src/message/handshake/sessioninit.rs6
-rw-r--r--src/message/handshake/types.rs6
-rw-r--r--src/message/signalproxy/heartbeat.rs26
-rw-r--r--src/message/signalproxy/initdata.rs2
-rw-r--r--src/message/signalproxy/initrequest.rs15
-rw-r--r--src/message/signalproxy/mod.rs18
-rw-r--r--src/message/signalproxy/objects/bufferviewmanager.rs26
-rw-r--r--src/message/signalproxy/objects/coreinfo.rs1
-rw-r--r--src/message/signalproxy/objects/highlightrulemanager.rs2
-rw-r--r--src/message/signalproxy/objects/identity.rs2
-rw-r--r--src/message/signalproxy/objects/ircchannel.rs4
-rw-r--r--src/message/signalproxy/objects/ircuser.rs2
-rw-r--r--src/message/signalproxy/objects/mod.rs62
-rw-r--r--src/message/signalproxy/objects/network.rs39
-rw-r--r--src/message/signalproxy/objects/networkinfo.rs2
-rw-r--r--src/message/signalproxy/rpccall/client.rs2
-rw-r--r--src/message/signalproxy/rpccall/identity.rs4
-rw-r--r--src/message/signalproxy/rpccall/mod.rs4
-rw-r--r--src/message/signalproxy/rpccall/network.rs6
-rw-r--r--src/message/signalproxy/rpccall/passwordchange.rs6
-rw-r--r--src/message/signalproxy/syncmessage.rs12
30 files changed, 146 insertions, 157 deletions
diff --git a/src/message/handshake/clientinit.rs b/src/message/handshake/clientinit.rs
index 94d52cf..9d35243 100644
--- a/src/message/handshake/clientinit.rs
+++ b/src/message/handshake/clientinit.rs
@@ -59,7 +59,7 @@ impl HandshakeSerialize for ClientInit {
"FeatureList".to_string(),
Variant::StringList(self.feature_list.clone()),
);
- return HandshakeSerialize::serialize(&values);
+ HandshakeSerialize::serialize(&values)
}
}
diff --git a/src/message/handshake/clientinitack.rs b/src/message/handshake/clientinitack.rs
index 21e65de..f3f4640 100644
--- a/src/message/handshake/clientinitack.rs
+++ b/src/message/handshake/clientinitack.rs
@@ -41,7 +41,7 @@ impl HandshakeSerialize for ClientInitAck {
"FeatureList".to_string(),
Variant::StringList(self.feature_list.clone()),
);
- return HandshakeSerialize::serialize(&values);
+ HandshakeSerialize::serialize(&values)
}
}
diff --git a/src/message/handshake/clientinitreject.rs b/src/message/handshake/clientinitreject.rs
index 7c4bb72..fca5388 100644
--- a/src/message/handshake/clientinitreject.rs
+++ b/src/message/handshake/clientinitreject.rs
@@ -17,7 +17,7 @@ impl HandshakeSerialize for ClientInitReject {
Variant::String("ClientInitReject".to_string()),
);
values.insert("ErrorString".to_string(), Variant::String(self.error.clone()));
- return HandshakeSerialize::serialize(&values);
+ HandshakeSerialize::serialize(&values)
}
}
diff --git a/src/message/handshake/clientlogin.rs b/src/message/handshake/clientlogin.rs
index b619e48..4be4442 100644
--- a/src/message/handshake/clientlogin.rs
+++ b/src/message/handshake/clientlogin.rs
@@ -16,7 +16,7 @@ impl HandshakeSerialize for ClientLogin {
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()));
- return HandshakeSerialize::serialize(&values);
+ HandshakeSerialize::serialize(&values)
}
}
diff --git a/src/message/handshake/clientloginack.rs b/src/message/handshake/clientloginack.rs
index 8a12f60..de26274 100644
--- a/src/message/handshake/clientloginack.rs
+++ b/src/message/handshake/clientloginack.rs
@@ -14,7 +14,7 @@ impl HandshakeSerialize for ClientLoginAck {
"MsgType".to_string(),
Variant::String("ClientLoginAck".to_string()),
);
- return HandshakeSerialize::serialize(&values);
+ HandshakeSerialize::serialize(&values)
}
}
diff --git a/src/message/handshake/connack.rs b/src/message/handshake/connack.rs
index d325cb9..e3accdd 100644
--- a/src/message/handshake/connack.rs
+++ b/src/message/handshake/connack.rs
@@ -47,13 +47,13 @@ impl crate::serialize::Deserialize for ConnAck {
let (elen, extra) = i16::parse(&b[flen..])?;
let (vlen, version) = i8::parse(&b[(flen + elen)..])?;
- return Ok((
+ Ok((
flen + elen + vlen,
Self {
flags,
extra,
version,
},
- ));
+ ))
}
}
diff --git a/src/message/handshake/features.rs b/src/message/handshake/features.rs
index e7557e9..af967d4 100644
--- a/src/message/handshake/features.rs
+++ b/src/message/handshake/features.rs
@@ -49,19 +49,18 @@ pub enum Feature {
impl Feature {
pub fn get() -> StringList {
- let mut features = StringList::new();
- features.push("ExtendedFeatures".to_string());
- #[cfg(feature = "long-message-id")]
- features.push("LongMessageId".to_string());
- #[cfg(feature = "long-time")]
- features.push("LongTime".to_string());
- #[cfg(feature = "rich-messages")]
- features.push("RichMessages".to_string());
- #[cfg(feature = "sender-prefixes")]
- features.push("SenderPrefixes".to_string());
- #[cfg(feature = "authenticators")]
- features.push("Authenticators".to_string());
-
- return features;
+ vec![
+ "ExtendedFeatures".to_string(),
+ #[cfg(feature = "long-message-id")]
+ "LongMessageId".to_string(),
+ #[cfg(feature = "long-time")]
+ "LongTime".to_string(),
+ #[cfg(feature = "rich-messages")]
+ "RichMessages".to_string(),
+ #[cfg(feature = "sender-prefixes")]
+ "SenderPrefixes".to_string(),
+ #[cfg(feature = "authenticators")]
+ "Authenticators".to_string(),
+ ]
}
}
diff --git a/src/message/handshake/init.rs b/src/message/handshake/init.rs
index 9f011ed..e303802 100644
--- a/src/message/handshake/init.rs
+++ b/src/message/handshake/init.rs
@@ -1,7 +1,7 @@
use crate::serialize::{Deserialize, Serialize};
/// The first few bytes sent to the core to initialize the connection and setup if we want to use tls and compression
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Default)]
pub struct Init {
pub tls: bool,
pub compression: bool,
@@ -9,10 +9,7 @@ pub struct Init {
impl Init {
pub fn new() -> Self {
- Self {
- tls: false,
- compression: false,
- }
+ Self::default()
}
pub fn compression(mut self, v: bool) -> Self {
@@ -47,7 +44,7 @@ impl Init {
init.extend(handshake.serialize().unwrap());
init.extend(crate::message::Protocol::Datastream.serialize());
- return init;
+ init
}
pub fn parse(buf: &[u8]) -> Self {
@@ -66,6 +63,6 @@ impl Init {
init.tls = true
}
- return init;
+ init
}
}
diff --git a/src/message/handshake/protocol.rs b/src/message/handshake/protocol.rs
index 73a82b9..2a7d9ac 100644
--- a/src/message/handshake/protocol.rs
+++ b/src/message/handshake/protocol.rs
@@ -1,13 +1,15 @@
use crate::serialize::{Deserialize, Serialize};
+#[derive(Debug, Default)]
pub enum Protocol {
Legacy = 0x00000001,
+ #[default]
Datastream = 0x00000002,
}
impl Protocol {
pub fn new() -> Self {
- Protocol::Datastream
+ Protocol::default()
}
pub fn serialize(self) -> Vec<u8> {
diff --git a/src/message/handshake/sessioninit.rs b/src/message/handshake/sessioninit.rs
index e2a29ad..b3a0932 100644
--- a/src/message/handshake/sessioninit.rs
+++ b/src/message/handshake/sessioninit.rs
@@ -37,7 +37,7 @@ impl From<VariantMap> for SessionInit {
network_ids: network_ids
.iter()
.map(|network| match network {
- Variant::NetworkId(network) => network.clone(),
+ Variant::NetworkId(network) => *network,
_ => unimplemented!(),
})
.collect(),
@@ -72,10 +72,10 @@ impl HandshakeSerialize for SessionInit {
Variant::VariantList(
self.network_ids
.iter()
- .map(|id| Variant::NetworkId(id.clone()))
+ .map(|id| Variant::NetworkId(*id))
.collect(),
),
);
- return HandshakeSerialize::serialize(&values);
+ HandshakeSerialize::serialize(&values)
}
}
diff --git a/src/message/handshake/types.rs b/src/message/handshake/types.rs
index bebeb4c..9bd8aec 100644
--- a/src/message/handshake/types.rs
+++ b/src/message/handshake/types.rs
@@ -10,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>, ProtocolError> {
+ fn serialize(&self) -> Result<Vec<u8>, ProtocolError> {
let mut res: Vec<u8> = Vec::new();
for (k, v) in self {
@@ -22,7 +22,7 @@ impl HandshakeSerialize for VariantMap {
let len: i32 = (self.len() * 2).try_into().unwrap();
util::insert_bytes(0, &mut res, &mut (len).to_be_bytes());
- return Ok(res);
+ Ok(res)
}
}
@@ -47,7 +47,7 @@ impl HandshakeDeserialize for VariantMap {
};
}
- return Ok((pos, map));
+ Ok((pos, map))
}
}
diff --git a/src/message/signalproxy/heartbeat.rs b/src/message/signalproxy/heartbeat.rs
index 7bb5b19..e7d17f3 100644
--- a/src/message/signalproxy/heartbeat.rs
+++ b/src/message/signalproxy/heartbeat.rs
@@ -10,18 +10,17 @@ pub struct HeartBeat {
impl Serialize for HeartBeat {
fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> {
- let mut res = VariantList::new();
-
- res.push(Variant::i32(MessageType::HeartBeat as i32));
- res.push(Variant::DateTime(self.timestamp.clone()));
-
- res.serialize()
+ vec![
+ Variant::i32(MessageType::HeartBeat as i32),
+ Variant::DateTime(self.timestamp),
+ ]
+ .serialize()
}
}
impl Deserialize for HeartBeat {
fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> {
- let (size, mut res) = VariantList::parse(&b)?;
+ let (size, mut res) = VariantList::parse(b)?;
res.remove(0);
@@ -41,18 +40,17 @@ pub struct HeartBeatReply {
impl Serialize for HeartBeatReply {
fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> {
- let mut res = VariantList::new();
-
- res.push(Variant::i32(MessageType::HeartBeatReply as i32));
- res.push(Variant::DateTime(self.timestamp.clone()));
-
- res.serialize()
+ vec![
+ Variant::i32(MessageType::HeartBeatReply as i32),
+ Variant::DateTime(self.timestamp),
+ ]
+ .serialize()
}
}
impl Deserialize for HeartBeatReply {
fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> {
- let (size, mut res) = VariantList::parse(&b)?;
+ 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 f95e0b2..c2ca6c6 100644
--- a/src/message/signalproxy/initdata.rs
+++ b/src/message/signalproxy/initdata.rs
@@ -28,7 +28,7 @@ impl Serialize for InitData {
impl Deserialize for InitData {
fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> {
- let (size, mut res) = VariantList::parse(&b)?;
+ 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 bf2f200..592a703 100644
--- a/src/message/signalproxy/initrequest.rs
+++ b/src/message/signalproxy/initrequest.rs
@@ -11,19 +11,18 @@ pub struct InitRequest {
impl Serialize for InitRequest {
fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> {
- let mut res = VariantList::new();
-
- res.push(Variant::i32(MessageType::InitRequest as i32));
- res.push(Variant::ByteArray(self.class_name.clone()));
- res.push(Variant::ByteArray(self.object_name.clone()));
-
- res.serialize()
+ vec![
+ Variant::i32(MessageType::InitRequest as i32),
+ Variant::ByteArray(self.class_name.clone()),
+ Variant::ByteArray(self.object_name.clone()),
+ ]
+ .serialize()
}
}
impl Deserialize for InitRequest {
fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> {
- let (size, mut res) = VariantList::parse(&b)?;
+ 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 5107e9b..90cf7e5 100644
--- a/src/message/signalproxy/mod.rs
+++ b/src/message/signalproxy/mod.rs
@@ -131,6 +131,7 @@ where
where
Self: Sized,
{
+ #[allow(clippy::match_single_binding)]
match msg.slot_name.as_str() {
_ => (),
}
@@ -170,6 +171,7 @@ pub trait StatefulSyncableClient: Syncable + translation::NetworkMap {
where
Self: Sized,
{
+ #[allow(clippy::match_single_binding)]
match msg.slot_name.as_str() {
_ => (),
}
@@ -199,7 +201,7 @@ pub enum Message {
/// Bidirectional
RpcCall(RpcCall),
InitRequest(InitRequest),
- InitData(InitData),
+ InitData(Box<InitData>),
/// Bidirectional
HeartBeat(HeartBeat),
/// Bidirectional
@@ -238,32 +240,32 @@ impl Deserialize for Message {
match MessageType::from(message_type) {
MessageType::SyncMessage => {
- let (size, res) = SyncMessage::parse(&b)?;
+ let (size, res) = SyncMessage::parse(b)?;
Ok((size, Message::SyncMessage(res)))
}
MessageType::RpcCall => {
- let (size, res) = RpcCall::parse(&b)?;
+ let (size, res) = RpcCall::parse(b)?;
Ok((size, Message::RpcCall(res)))
}
MessageType::InitRequest => {
- let (size, res) = InitRequest::parse(&b)?;
+ let (size, res) = InitRequest::parse(b)?;
Ok((size, Message::InitRequest(res)))
}
MessageType::InitData => {
- let (size, res) = InitData::parse(&b)?;
+ let (size, res) = InitData::parse(b)?;
- Ok((size, Message::InitData(res)))
+ Ok((size, Message::InitData(Box::new(res))))
}
MessageType::HeartBeat => {
- let (size, res) = HeartBeat::parse(&b)?;
+ let (size, res) = HeartBeat::parse(b)?;
Ok((size, Message::HeartBeat(res)))
}
MessageType::HeartBeatReply => {
- let (size, res) = HeartBeatReply::parse(&b)?;
+ let (size, res) = HeartBeatReply::parse(b)?;
Ok((size, Message::HeartBeatReply(res)))
}
diff --git a/src/message/signalproxy/objects/bufferviewmanager.rs b/src/message/signalproxy/objects/bufferviewmanager.rs
index 683d937..1097ade 100644
--- a/src/message/signalproxy/objects/bufferviewmanager.rs
+++ b/src/message/signalproxy/objects/bufferviewmanager.rs
@@ -133,23 +133,16 @@ impl Syncable for BufferViewManager {
impl super::NetworkList for BufferViewManager {
fn to_network_list(&self) -> VariantList {
- let mut res = Vec::with_capacity(2);
-
- res.push(Variant::ByteArray(s!("bufferViewIds")));
- res.push(Variant::VariantList(
- self.buffer_view_configs
- .iter()
- .map(|(k, _)| i32::try_into(*k).unwrap())
- .collect(),
- ));
-
- return res;
+ vec![
+ Variant::ByteArray(s!("bufferViewIds")),
+ Variant::VariantList(self.buffer_view_configs.keys().map(|k| i32::into(*k)).collect()),
+ ]
}
fn from_network_list(input: &mut VariantList) -> Self {
let mut i = input.iter();
i.position(|x| *x == Variant::ByteArray(String::from("BufferViewIds")))
- .expect(format!("failed to get field BufferViewIds").as_str());
+ .expect("failed to get field BufferViewIds");
let ids = match i.next().expect("failed to get next field") {
libquassel::primitive::Variant::VariantList(var) => var.clone(),
@@ -174,15 +167,10 @@ impl super::NetworkMap for BufferViewManager {
res.insert(
s!("bufferViewIds"),
- Variant::VariantList(
- self.buffer_view_configs
- .iter()
- .map(|(k, _)| i32::try_into(*k).unwrap())
- .collect(),
- ),
+ Variant::VariantList(self.buffer_view_configs.keys().map(|k| i32::into(*k)).collect()),
);
- return res;
+ res
}
fn from_network_map(_input: &mut Self::Item) -> Self {
diff --git a/src/message/signalproxy/objects/coreinfo.rs b/src/message/signalproxy/objects/coreinfo.rs
index 4567762..5036abd 100644
--- a/src/message/signalproxy/objects/coreinfo.rs
+++ b/src/message/signalproxy/objects/coreinfo.rs
@@ -26,6 +26,7 @@ impl crate::message::StatefulSyncableClient for CoreInfo {
where
Self: Sized,
{
+ #[allow(clippy::single_match)]
match msg.slot_name.as_str() {
"setCoreData" => self.set_core_data(CoreData::from_network_map(&mut get_param!(msg))),
_ => (),
diff --git a/src/message/signalproxy/objects/highlightrulemanager.rs b/src/message/signalproxy/objects/highlightrulemanager.rs
index 0f1569a..7accb17 100644
--- a/src/message/signalproxy/objects/highlightrulemanager.rs
+++ b/src/message/signalproxy/objects/highlightrulemanager.rs
@@ -223,8 +223,10 @@ 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()
}
}
diff --git a/src/message/signalproxy/objects/identity.rs b/src/message/signalproxy/objects/identity.rs
index 6aa9830..ec7d9b4 100644
--- a/src/message/signalproxy/objects/identity.rs
+++ b/src/message/signalproxy/objects/identity.rs
@@ -81,7 +81,7 @@ impl Deserialize for Identity {
Self: std::marker::Sized,
{
let (vlen, mut value) = VariantMap::parse(b)?;
- return Ok((vlen, Self::from_network_map(&mut value)));
+ Ok((vlen, Self::from_network_map(&mut value)))
}
}
diff --git a/src/message/signalproxy/objects/ircchannel.rs b/src/message/signalproxy/objects/ircchannel.rs
index 9ca3474..9648210 100644
--- a/src/message/signalproxy/objects/ircchannel.rs
+++ b/src/message/signalproxy/objects/ircchannel.rs
@@ -47,7 +47,7 @@ impl Deserialize for IrcChannel {
Self: std::marker::Sized,
{
let (vlen, mut value) = VariantMap::parse(b)?;
- return Ok((vlen, Self::from_network_map(&mut value)));
+ Ok((vlen, Self::from_network_map(&mut value)))
}
}
@@ -155,7 +155,7 @@ impl IrcChannel {
None => warn!("tried to remove a user that is not joined to the channel"),
}
- if self.user_modes.len() == 0
+ if self.user_modes.is_empty()
/* nick.is_me() */
{
// TODO Clean up channel and delete
diff --git a/src/message/signalproxy/objects/ircuser.rs b/src/message/signalproxy/objects/ircuser.rs
index 1969793..3b807ed 100644
--- a/src/message/signalproxy/objects/ircuser.rs
+++ b/src/message/signalproxy/objects/ircuser.rs
@@ -59,7 +59,7 @@ impl Deserialize for IrcUser {
Self: std::marker::Sized,
{
let (vlen, mut value) = VariantMap::parse(b)?;
- return Ok((vlen, Self::from_network_map(&mut value)));
+ Ok((vlen, Self::from_network_map(&mut value)))
}
}
diff --git a/src/message/signalproxy/objects/mod.rs b/src/message/signalproxy/objects/mod.rs
index 0fb16c6..999cd41 100644
--- a/src/message/signalproxy/objects/mod.rs
+++ b/src/message/signalproxy/objects/mod.rs
@@ -60,20 +60,20 @@ use crate::primitive::VariantList;
// TODO Handle SyncedCoreInfo feature flag
#[derive(Debug, Clone, PartialEq, From)]
pub enum Types {
- AliasManager(AliasManager),
- BufferSyncer(BufferSyncer),
- BufferViewConfig(BufferViewConfig),
- BufferViewManager(BufferViewManager),
- // CoreInfo(CoreInfo),
- CoreData(CoreData),
- HighlightRuleManager(HighlightRuleManager),
- IgnoreListManager(IgnoreListManager),
- CertManager(CertManager),
- Network(network::Network),
- NetworkInfo(NetworkInfo),
- NetworkConfig(NetworkConfig),
- IrcChannel(IrcChannel),
- Unknown(VariantList),
+ AliasManager(Box<AliasManager>),
+ BufferSyncer(Box<BufferSyncer>),
+ BufferViewConfig(Box<BufferViewConfig>),
+ BufferViewManager(Box<BufferViewManager>),
+ // CoreInfo(Box< CoreInfo >),
+ CoreData(Box<CoreData>),
+ HighlightRuleManager(Box<HighlightRuleManager>),
+ IgnoreListManager(Box<IgnoreListManager>),
+ CertManager(Box<CertManager>),
+ Network(Box<network::Network>),
+ NetworkInfo(Box<NetworkInfo>),
+ NetworkConfig(Box<NetworkConfig>),
+ IrcChannel(Box<IrcChannel>),
+ Unknown(Box<VariantList>),
}
impl Types {
@@ -93,37 +93,41 @@ impl Types {
Types::NetworkInfo(val) => val.to_network_list(),
Types::NetworkConfig(val) => val.to_network_list(),
Types::IrcChannel(val) => val.to_network_list(),
- Types::Unknown(val) => val.clone(),
+ Types::Unknown(val) => *val.clone(),
}
}
pub fn from_network(class_name: &str, object_name: &str, input: &mut VariantList) -> Self {
debug!("converting {} from network object: {:#?}", class_name, input);
match class_name {
- "AliasManager" => Types::AliasManager(AliasManager::from_network_list(input)),
- "BufferSyncer" => Types::BufferSyncer(BufferSyncer::from_network_list(input)),
+ "AliasManager" => Types::AliasManager(Box::new(AliasManager::from_network_list(input))),
+ "BufferSyncer" => Types::BufferSyncer(Box::new(BufferSyncer::from_network_list(input))),
"BufferViewConfig" => {
let mut config = BufferViewConfig::from_network_list(input);
config.buffer_view_id = object_name.parse().unwrap();
- Types::BufferViewConfig(config)
+ Types::BufferViewConfig(Box::new(config))
+ }
+ "BufferViewManager" => {
+ Types::BufferViewManager(Box::new(BufferViewManager::from_network_list(input)))
}
- "BufferViewManager" => Types::BufferViewManager(BufferViewManager::from_network_list(input)),
// "CoreInfo" => Types::CoreInfo(CoreInfo::from_network_map(
// &mut input.remove(0).try_into().unwrap(),
// )),
- "CoreData" => Types::CoreData(CoreData::from_network_map(
+ "CoreData" => Types::CoreData(Box::new(CoreData::from_network_map(
&mut input.remove(0).try_into().unwrap(),
- )),
+ ))),
"HighlightRuleManager" => {
- Types::HighlightRuleManager(HighlightRuleManager::from_network_list(input))
+ Types::HighlightRuleManager(Box::new(HighlightRuleManager::from_network_list(input)))
+ }
+ "IgnoreListManager" => {
+ Types::IgnoreListManager(Box::new(IgnoreListManager::from_network_list(input)))
}
- "IgnoreListManager" => Types::IgnoreListManager(IgnoreListManager::from_network_list(input)),
- "CertManager" => Types::CertManager(CertManager::from_network_list(input)),
- "Network" => Types::Network(Network::from_network_list(input)),
- "NetworkInfo" => Types::NetworkInfo(NetworkInfo::from_network_list(input)),
- "NetworkConfig" => Types::NetworkConfig(NetworkConfig::from_network_list(input)),
- "IrcChannel" => Types::IrcChannel(IrcChannel::from_network_list(input)),
- _ => Types::Unknown(input.to_owned()),
+ "CertManager" => Types::CertManager(Box::new(CertManager::from_network_list(input))),
+ "Network" => Types::Network(Box::new(Network::from_network_list(input))),
+ "NetworkInfo" => Types::NetworkInfo(Box::new(NetworkInfo::from_network_list(input))),
+ "NetworkConfig" => Types::NetworkConfig(Box::new(NetworkConfig::from_network_list(input))),
+ "IrcChannel" => Types::IrcChannel(Box::new(IrcChannel::from_network_list(input))),
+ _ => Types::Unknown(Box::new(input.to_owned())),
}
}
}
diff --git a/src/message/signalproxy/objects/network.rs b/src/message/signalproxy/objects/network.rs
index a606537..3d2ee8b 100644
--- a/src/message/signalproxy/objects/network.rs
+++ b/src/message/signalproxy/objects/network.rs
@@ -71,23 +71,19 @@ impl Network {
let default_prefixes = vec!['~', '&', '@', '%', '+'];
let default_prefix_modes = vec!['q', 'a', 'o', 'h', 'v'];
- match self.supports.get("PREFIX") {
- Some(prefix) => {
- if prefix.starts_with('(') {
- let (prefix_modes, prefixes) = prefix[1..].split_once(')').unwrap();
-
- self.prefix_modes = prefix_modes.chars().collect();
- self.prefixes = prefixes.chars().collect();
- } else {
- self.prefixes = default_prefixes;
- self.prefix_modes = default_prefix_modes;
- }
- }
- None => {
- self.prefixes = default_prefixes;
- self.prefix_modes = default_prefix_modes;
+ if let Some(prefix) = self.supports.get("PREFIX") {
+ if let Some(prefix) = prefix.strip_prefix('(') {
+ let (prefix_modes, prefixes) = prefix.split_once(')').unwrap();
+
+ self.prefix_modes = prefix_modes.chars().collect();
+ self.prefixes = prefixes.chars().collect();
+
+ return;
}
}
+
+ self.prefixes = default_prefixes;
+ self.prefix_modes = default_prefix_modes;
}
pub fn add_channel(&mut self, name: &str, channel: IrcChannel) {
@@ -280,6 +276,7 @@ impl crate::message::StatefulSyncableServer for Network {
impl crate::message::signalproxy::NetworkList for Network {
fn to_network_list(&self) -> VariantList {
+ #![allow(clippy::vec_init_then_push)]
let mut res = VariantList::new();
res.push(Variant::ByteArray(s!("myNick")));
@@ -449,7 +446,7 @@ impl crate::message::signalproxy::NetworkList for Network {
network.determine_channel_mode_types();
network.determine_prefixes();
- return network;
+ network
}
}
@@ -526,7 +523,7 @@ impl crate::message::signalproxy::NetworkMap for Network {
res.extend(self.network_info.to_network_map());
- return res;
+ res
}
fn from_network_map(input: &mut Self::Item) -> Self {
@@ -648,7 +645,7 @@ impl Deserialize for NetworkServer {
Self: std::marker::Sized,
{
let (vlen, mut value) = VariantMap::parse(b)?;
- return Ok((vlen, Self::from_network_map(&mut value)));
+ Ok((vlen, Self::from_network_map(&mut value)))
}
}
@@ -802,9 +799,9 @@ impl Default for ConnectionState {
}
}
-impl Into<Variant> for ConnectionState {
- fn into(self) -> Variant {
- Variant::i32(self.to_i32().unwrap())
+impl From<ConnectionState> for Variant {
+ fn from(val: ConnectionState) -> Self {
+ Variant::i32(val.to_i32().unwrap())
}
}
diff --git a/src/message/signalproxy/objects/networkinfo.rs b/src/message/signalproxy/objects/networkinfo.rs
index 4cd84dc..ba944e8 100644
--- a/src/message/signalproxy/objects/networkinfo.rs
+++ b/src/message/signalproxy/objects/networkinfo.rs
@@ -88,7 +88,7 @@ impl Deserialize for NetworkInfo {
Self: std::marker::Sized,
{
let (vlen, mut value) = VariantMap::parse(b)?;
- return Ok((vlen, Self::from_network_map(&mut value)));
+ Ok((vlen, Self::from_network_map(&mut value)))
}
}
diff --git a/src/message/signalproxy/rpccall/client.rs b/src/message/signalproxy/rpccall/client.rs
index 818b32c..7e31135 100644
--- a/src/message/signalproxy/rpccall/client.rs
+++ b/src/message/signalproxy/rpccall/client.rs
@@ -15,7 +15,7 @@ impl RpcCallType for KickClient {
fn to_network(&self) -> Result<Vec<crate::primitive::Variant>, crate::ProtocolError> {
Ok(vec![
Variant::ByteArray(Self::NAME.to_string()),
- self.id.clone().into(),
+ self.id.into(),
])
}
diff --git a/src/message/signalproxy/rpccall/identity.rs b/src/message/signalproxy/rpccall/identity.rs
index 1672e98..15beec4 100644
--- a/src/message/signalproxy/rpccall/identity.rs
+++ b/src/message/signalproxy/rpccall/identity.rs
@@ -54,7 +54,7 @@ impl RpcCallType for RemoveIdentity {
fn to_network(&self) -> Result<Vec<crate::primitive::Variant>, crate::ProtocolError> {
Ok(vec![
Variant::ByteArray(Self::NAME.to_string()),
- Variant::IdentityId(self.identity_id.clone()),
+ Variant::IdentityId(self.identity_id),
])
}
@@ -120,7 +120,7 @@ impl RpcCallType for IdentityRemoved {
fn to_network(&self) -> Result<Vec<crate::primitive::Variant>, crate::ProtocolError> {
Ok(vec![
Variant::ByteArray(Self::NAME.to_string()),
- Variant::IdentityId(self.identity_id.clone()),
+ Variant::IdentityId(self.identity_id),
])
}
diff --git a/src/message/signalproxy/rpccall/mod.rs b/src/message/signalproxy/rpccall/mod.rs
index c30d462..2a3e7b1 100644
--- a/src/message/signalproxy/rpccall/mod.rs
+++ b/src/message/signalproxy/rpccall/mod.rs
@@ -106,7 +106,7 @@ impl Serialize for RpcCall {
impl Deserialize for RpcCall {
fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), ProtocolError> {
- let (size, mut res) = VariantList::parse(&b)?;
+ let (size, mut res) = VariantList::parse(b)?;
res.remove(0);
@@ -130,7 +130,7 @@ impl Deserialize for RpcCall {
DisconnectFromCore::NAME => DisconnectFromCore::from_network(size, &mut res),
ObjectRenamed::NAME => ObjectRenamed::from_network(size, &mut res),
BufferInfoUpdated::NAME => BufferInfoUpdated::from_network(size, &mut res),
- _ => return Ok((size, RpcCall::NotImplemented)),
+ _ => Ok((size, RpcCall::NotImplemented)),
}
}
}
diff --git a/src/message/signalproxy/rpccall/network.rs b/src/message/signalproxy/rpccall/network.rs
index aeb3f80..738dddf 100644
--- a/src/message/signalproxy/rpccall/network.rs
+++ b/src/message/signalproxy/rpccall/network.rs
@@ -53,7 +53,7 @@ impl RpcCallType for RemoveNetwork {
fn to_network(&self) -> Result<Vec<crate::primitive::Variant>, crate::ProtocolError> {
Ok(vec![
Variant::ByteArray(Self::NAME.to_string()),
- self.network_id.clone().into(),
+ self.network_id.into(),
])
}
@@ -86,7 +86,7 @@ impl RpcCallType for NetworkCreated {
fn to_network(&self) -> Result<Vec<crate::primitive::Variant>, crate::ProtocolError> {
Ok(vec![
Variant::ByteArray(Self::NAME.to_string()),
- self.network_id.clone().into(),
+ self.network_id.into(),
])
}
@@ -119,7 +119,7 @@ impl RpcCallType for NetworkRemoved {
fn to_network(&self) -> Result<Vec<crate::primitive::Variant>, crate::ProtocolError> {
Ok(vec![
Variant::ByteArray(Self::NAME.to_string()),
- self.network_id.clone().into(),
+ self.network_id.into(),
])
}
diff --git a/src/message/signalproxy/rpccall/passwordchange.rs b/src/message/signalproxy/rpccall/passwordchange.rs
index b96b926..16bf78f 100644
--- a/src/message/signalproxy/rpccall/passwordchange.rs
+++ b/src/message/signalproxy/rpccall/passwordchange.rs
@@ -21,7 +21,7 @@ impl RpcCallType for ChangePassword {
fn to_network(&self) -> Result<Vec<crate::primitive::Variant>, crate::ProtocolError> {
Ok(vec![
Variant::ByteArray(Self::NAME.to_string()),
- self.peer.clone().into(),
+ self.peer.into(),
self.user.clone().into(),
self.before.clone().into(),
self.after.clone().into(),
@@ -64,8 +64,8 @@ impl RpcCallType for PasswordChanged {
fn to_network(&self) -> Result<Vec<crate::primitive::Variant>, crate::ProtocolError> {
Ok(vec![
Variant::ByteArray(Self::NAME.to_string()),
- self.peer.clone().into(),
- self.success.clone().into(),
+ self.peer.into(),
+ self.success.into(),
])
}
diff --git a/src/message/signalproxy/syncmessage.rs b/src/message/signalproxy/syncmessage.rs
index bb61d7c..b124d07 100644
--- a/src/message/signalproxy/syncmessage.rs
+++ b/src/message/signalproxy/syncmessage.rs
@@ -90,12 +90,12 @@ pub struct SyncMessage {
impl Serialize for SyncMessage {
fn serialize(&self) -> Result<Vec<std::primitive::u8>, ProtocolError> {
- let mut res = VariantList::new();
-
- res.push(Variant::i32(MessageType::SyncMessage as i32));
- res.push(Variant::ByteArray(self.class_name.as_str().to_owned()));
- res.push(Variant::ByteArray(self.object_name.clone()));
- res.push(Variant::ByteArray(self.slot_name.clone()));
+ let mut res = vec![
+ Variant::i32(MessageType::SyncMessage as i32),
+ Variant::ByteArray(self.class_name.as_str().to_owned()),
+ Variant::ByteArray(self.object_name.clone()),
+ Variant::ByteArray(self.slot_name.clone()),
+ ];
res.append(&mut self.params.clone());