Browse Source

PSOPacket::from_bytes &Vec<u8> -> &[u8]

pull/3/head
Jake Probst 5 years ago
parent
commit
a37856ddcf
  1. 2
      psopacket/src/lib.rs
  2. 2
      src/lib.rs
  3. 2
      src/packet/patch.rs

2
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<u8>) -> 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();

2
src/lib.rs

@ -14,7 +14,7 @@ pub enum PacketParseError {
pub trait PSOPacket: std::fmt::Debug {
fn from_bytes(data: &Vec<u8>) -> Result<Self, PacketParseError> where Self: Sized;
fn from_bytes(data: &[u8]) -> Result<Self, PacketParseError> where Self: Sized;
fn as_bytes(&self) -> Vec<u8>;
}

2
src/packet/patch.rs

@ -76,7 +76,7 @@ pub struct FileSend {
}
impl PSOPacket for FileSend {
fn from_bytes(_data: &Vec<u8>) -> Result<FileSend, PacketParseError> {
fn from_bytes(_data: &[u8]) -> Result<FileSend, PacketParseError> {
// TODO: implement this? it shouldn't be called on the server side ever...
unimplemented!();
}

Loading…
Cancel
Save