PSOPacket::from_bytes &Vec<u8> -> &[u8]
This commit is contained in:
		
							parent
							
								
									5fbfce058c
								
							
						
					
					
						commit
						a37856ddcf
					
				| @ -222,7 +222,7 @@ pub fn pso_packet(attr: TokenStream, item: TokenStream) -> TokenStream { | |||||||
| 
 | 
 | ||||||
|     let psopacket = quote! { |     let psopacket = quote! { | ||||||
|         impl PSOPacket for #this_struct { |         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 cur = std::io::Cursor::new(data); | ||||||
|                 let mut b: [u8; 2] = [0; 2]; |                 let mut b: [u8; 2] = [0; 2]; | ||||||
|                 cur.read(&mut b).unwrap(); |                 cur.read(&mut b).unwrap(); | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ pub enum PacketParseError { | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| pub trait PSOPacket: std::fmt::Debug { | 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>; |     fn as_bytes(&self) -> Vec<u8>; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -76,7 +76,7 @@ pub struct FileSend { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl PSOPacket for 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...
 |         // TODO: implement this? it shouldn't be called on the server side ever...
 | ||||||
|         unimplemented!(); |         unimplemented!(); | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user