serialize any type that provides information on how to
This commit is contained in:
		
							parent
							
								
									7ae27273b4
								
							
						
					
					
						commit
						a8b5559ac0
					
				@ -187,8 +187,22 @@ pub fn pso_packet(attr: TokenStream, item: TokenStream) -> TokenStream {
 | 
				
			|||||||
                            });
 | 
					                            });
 | 
				
			||||||
                        },
 | 
					                        },
 | 
				
			||||||
                        _ => {
 | 
					                        _ => {
 | 
				
			||||||
                            return syn::Error::new(path.path.segments[0].ident.span(), "type not supported")
 | 
					                            from_bytes.push(quote! {
 | 
				
			||||||
                                .to_compile_error().into();
 | 
					                                #ident: {
 | 
				
			||||||
 | 
					                                    let mut b: [u8; #path::SIZE] = [0; #path::SIZE];
 | 
				
			||||||
 | 
					                                    if let Ok(len) = cur.read(&mut b) {
 | 
				
			||||||
 | 
					                                        if len != #path::SIZE {
 | 
				
			||||||
 | 
					                                            return Err(PacketParseError::NotEnoughBytes);
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                    else {
 | 
				
			||||||
 | 
					                                        return Err(PacketParseError::NotEnoughBytes);
 | 
				
			||||||
 | 
					                                    };
 | 
				
			||||||
 | 
					                                    #path::from_le_bytes(b)?
 | 
				
			||||||
 | 
					                                },
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
 | 
					                            //return syn::Error::new(path.path.segments[0].ident.span(), "type not supported")
 | 
				
			||||||
 | 
					                            //    .to_compile_error().into();
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    partialeq.push(quote! {
 | 
					                    partialeq.push(quote! {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user