|
|
@ -80,6 +80,40 @@ pub fn pso_packet(attr: TokenStream, item: TokenStream) -> TokenStream { |
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
"u16" => {
|
|
|
|
from_bytes.push(quote! {
|
|
|
|
#ident: {
|
|
|
|
let mut b: [u16; #array_length] = [0; #array_length];
|
|
|
|
if let Ok(len) = cur.read(&mut b) {
|
|
|
|
if len != #array_length {
|
|
|
|
return Err(PacketParseError::NotEnoughBytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return Err(PacketParseError::NotEnoughBytes);
|
|
|
|
};
|
|
|
|
b
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
"u32" => {
|
|
|
|
from_bytes.push(quote! {
|
|
|
|
#ident: {
|
|
|
|
let mut b: [u32; #array_length] = [0; #array_length];
|
|
|
|
if let Ok(len) = cur.read(&mut b) {
|
|
|
|
if len != #array_length {
|
|
|
|
return Err(PacketParseError::NotEnoughBytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return Err(PacketParseError::NotEnoughBytes);
|
|
|
|
};
|
|
|
|
b
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_ => {
|
|
|
|
return syn::Error::new(path.path.segments[0].ident.span(), "type not supported")
|
|
|
|
.to_compile_error().into();
|
|
|
|