From a37856ddcff00e69fcfc70acc32d8a66554b4653 Mon Sep 17 00:00:00 2001 From: Jake Probst Date: Wed, 4 Sep 2019 09:09:01 -0700 Subject: [PATCH] PSOPacket::from_bytes &Vec -> &[u8] --- psopacket/src/lib.rs | 2 +- src/lib.rs | 2 +- src/packet/patch.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/psopacket/src/lib.rs b/psopacket/src/lib.rs index 91d4b97..cc621c4 100644 --- a/psopacket/src/lib.rs +++ b/psopacket/src/lib.rs @@ -222,7 +222,7 @@ pub fn pso_packet(attr: TokenStream, item: TokenStream) -> TokenStream { let psopacket = quote! { impl PSOPacket for #this_struct { - fn from_bytes(data: &Vec) -> Result<#this_struct, PacketParseError> { + fn from_bytes(data: &[u8]) -> Result<#this_struct, PacketParseError> { let mut cur = std::io::Cursor::new(data); let mut b: [u8; 2] = [0; 2]; cur.read(&mut b).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 9920921..272503c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ pub enum PacketParseError { pub trait PSOPacket: std::fmt::Debug { - fn from_bytes(data: &Vec) -> Result where Self: Sized; + fn from_bytes(data: &[u8]) -> Result where Self: Sized; fn as_bytes(&self) -> Vec; } diff --git a/src/packet/patch.rs b/src/packet/patch.rs index b3f8102..71165f4 100644 --- a/src/packet/patch.rs +++ b/src/packet/patch.rs @@ -76,7 +76,7 @@ pub struct FileSend { } impl PSOPacket for FileSend { - fn from_bytes(_data: &Vec) -> Result { + fn from_bytes(_data: &[u8]) -> Result { // TODO: implement this? it shouldn't be called on the server side ever... unimplemented!(); }