aboutsummaryrefslogtreecommitdiff
path: root/src/message/handshake/protocol.rs
diff options
context:
space:
mode:
authorMax Audron <me@audron.dev>2026-02-22 14:06:16 +0100
committerMax Audron <me@audron.dev>2026-02-22 14:06:16 +0100
commit024eb3df4a0786a92033baea123aa779998cdc28 (patch)
tree412670a982455cb3351c199b7df21b0b22f3a36e /src/message/handshake/protocol.rs
parentSyncable trait error handling (diff)
NetworkList and signalproxy objects error handling
Diffstat (limited to 'src/message/handshake/protocol.rs')
-rw-r--r--src/message/handshake/protocol.rs15
1 files changed, 9 insertions, 6 deletions
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<u8> {
+ pub fn serialize(self) -> Result<Vec<u8>, ProtocolError> {
let proto: u32 = 0x80000002;
- proto.serialize().unwrap()
+ proto.serialize()
}
- pub fn parse(buf: &[u8]) -> Self {
+ pub fn parse(buf: &[u8]) -> Result<Self, ProtocolError> {
let mut protolist: Vec<u32> = 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)
}
}