diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/primitive/bufferinfo.rs | 11 | ||||
| -rw-r--r-- | src/primitive/message.rs | 6 | ||||
| -rw-r--r-- | src/primitive/variant.rs | 4 |
3 files changed, 11 insertions, 10 deletions
diff --git a/src/primitive/bufferinfo.rs b/src/primitive/bufferinfo.rs index a87c418..0383bc4 100644 --- a/src/primitive/bufferinfo.rs +++ b/src/primitive/bufferinfo.rs @@ -1,5 +1,6 @@ use std::vec::Vec; +use crate::primitive::BufferId; use crate::{deserialize::*, error::ProtocolError, serialize::*}; /// The BufferInfo struct represents a BufferInfo as received in IRC @@ -8,7 +9,7 @@ use crate::{deserialize::*, error::ProtocolError, serialize::*}; #[derive(Clone, Debug, std::cmp::PartialEq)] pub struct BufferInfo { /// a unique, sequential id for the buffer - pub id: i32, + pub id: BufferId, /// NetworkId of the network the buffer belongs to pub network_id: i32, /// The Type of the Buffer @@ -21,7 +22,7 @@ impl Serialize for BufferInfo { fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { let mut values: Vec<u8> = Vec::new(); - values.append(&mut i32::serialize(&self.id)?); + values.append(&mut BufferId::serialize(&self.id)?); values.append(&mut i32::serialize(&self.network_id)?); values.append(&mut i16::serialize(&(self.buffer_type as i16))?); values.append(&mut vec![0, 0, 0, 0]); @@ -33,7 +34,7 @@ impl Serialize for BufferInfo { impl Deserialize for BufferInfo { fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> { - let (_, id) = i32::parse(&b[0..4])?; + let (_, id) = BufferId::parse(&b[0..4])?; let (_, network_id) = i32::parse(&b[4..8])?; let (_, buffer_type) = i16::parse(&b[8..10])?; @@ -83,7 +84,7 @@ mod tests { #[test] fn bufferinfo_serialize() { let buffer = BufferInfo { - id: 1, + id: BufferId(1), network_id: 1, buffer_type: BufferType::Channel, name: "#test".to_string(), @@ -98,7 +99,7 @@ mod tests { #[test] fn bufferinfo_deserialize() { let buffer = BufferInfo { - id: 1, + id: BufferId(1), network_id: 1, buffer_type: BufferType::Channel, name: "#test".to_string(), diff --git a/src/primitive/message.rs b/src/primitive/message.rs index 6389eda..3d6f560 100644 --- a/src/primitive/message.rs +++ b/src/primitive/message.rs @@ -251,7 +251,7 @@ where #[cfg(feature = "all-quassel-features")] mod tests { use super::*; - use crate::primitive::{BufferInfo, BufferType}; + use crate::primitive::{BufferId, BufferInfo, BufferType}; #[test] fn message_serialize() { @@ -261,7 +261,7 @@ mod tests { msg_type: MessageType::PLAIN, flags: 0, buffer: BufferInfo { - id: 1, + id: BufferId(1), network_id: 1, buffer_type: BufferType::Channel, name: "#test".to_string(), @@ -294,7 +294,7 @@ mod tests { msg_type: MessageType::PLAIN, flags: 0, buffer: BufferInfo { - id: 1, + id: BufferId(1), network_id: 1, buffer_type: BufferType::Channel, name: "#test".to_string(), diff --git a/src/primitive/variant.rs b/src/primitive/variant.rs index 6abeba3..340d908 100644 --- a/src/primitive/variant.rs +++ b/src/primitive/variant.rs @@ -605,7 +605,7 @@ mod tests { #[test] pub fn buffer_info_serialize() { let test_buffer_info = BufferInfo { - id: 0, + id: BufferId(0), network_id: 0, buffer_type: primitive::BufferType::Status, name: "test".to_string(), @@ -621,7 +621,7 @@ mod tests { #[test] pub fn buffer_info_deserialize() { let test_buffer_info = BufferInfo { - id: 0, + id: BufferId(0), network_id: 0, buffer_type: primitive::BufferType::Status, name: "test".to_string(), |
