From 024eb3df4a0786a92033baea123aa779998cdc28 Mon Sep 17 00:00:00 2001 From: Max Audron Date: Sun, 22 Feb 2026 14:06:16 +0100 Subject: NetworkList and signalproxy objects error handling --- src/message/handshake/protocol.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/message/handshake/protocol.rs') diff --git a/src/message/handshake/protocol.rs b/src/message/handshake/protocol.rs index 2a7d9ac..0dc419f 100644 --- a/src/message/handshake/protocol.rs +++ b/src/message/handshake/protocol.rs @@ -1,4 +1,7 @@ -use crate::serialize::{Deserialize, Serialize}; +use crate::{ + serialize::{Deserialize, Serialize}, + ProtocolError, +}; #[derive(Debug, Default)] pub enum Protocol { @@ -12,17 +15,17 @@ impl Protocol { Protocol::default() } - pub fn serialize(self) -> Vec { + pub fn serialize(self) -> Result, ProtocolError> { let proto: u32 = 0x80000002; - proto.serialize().unwrap() + proto.serialize() } - pub fn parse(buf: &[u8]) -> Self { + pub fn parse(buf: &[u8]) -> Result { let mut protolist: Vec = Vec::new(); let mut pos = 0; loop { - let (_, proto) = u32::parse(&buf[pos..(pos + 4)]).unwrap(); + let (_, proto) = u32::parse(&buf[pos..(pos + 4)])?; if (proto & 0x80000000) >= 1 { protolist.push(proto - 0x80000000); break; @@ -32,6 +35,6 @@ impl Protocol { } } - Protocol::Datastream + Ok(Protocol::Datastream) } } -- cgit v1.2.3