aboutsummaryrefslogtreecommitdiff
path: root/src/primitive/bufferinfo.rs
diff options
context:
space:
mode:
authorTobias Deiminger <tdmg@linutronix.de>2024-04-16 22:06:52 +0200
committerMax Audron <audron@cocaine.farm>2025-02-25 00:11:49 +0100
commit8b50c49e2476bcce5b13b1e604a4bcca22eab3ff (patch)
treec625bfdd160ab20e25d49de785f8b5a27b74d76c /src/primitive/bufferinfo.rs
parentUse BufferId in Variant (diff)
Use BufferId in BufferInfo
Diffstat (limited to 'src/primitive/bufferinfo.rs')
-rw-r--r--src/primitive/bufferinfo.rs11
1 files changed, 6 insertions, 5 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(),