feat: bincode_1_3 by default
This commit is contained in:
@@ -16,7 +16,6 @@ use syn::token;
|
||||
use syn::{parse_macro_input, DeriveInput, LitInt, Path, Token};
|
||||
|
||||
// Inspiration: https://docs.rs/syn/2.0.29/syn/meta/fn.parser.html#example-1
|
||||
#[derive(Default)]
|
||||
pub(crate) struct ModelAttributes {
|
||||
pub(crate) id: Option<LitInt>,
|
||||
pub(crate) version: Option<LitInt>,
|
||||
@@ -28,6 +27,18 @@ pub(crate) struct ModelAttributes {
|
||||
pub(crate) try_from: Option<(Path, Path)>,
|
||||
}
|
||||
|
||||
impl Default for ModelAttributes {
|
||||
fn default() -> Self {
|
||||
ModelAttributes {
|
||||
id: None,
|
||||
version: None,
|
||||
with: Some(syn::parse_str::<Path>("native_model::bincode_1_3::Bincode").unwrap()),
|
||||
from: None,
|
||||
try_from: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ModelAttributes {
|
||||
fn parse(&mut self, meta: ParseNestedMeta) -> Result<()> {
|
||||
if meta.path.is_ident("id") {
|
||||
|
||||
@@ -7,7 +7,6 @@ pub(crate) fn generate_native_model_decode_body(attrs: &ModelAttributes) -> Toke
|
||||
let with = attrs.with.clone().expect("`with` is required");
|
||||
let gen = quote! {
|
||||
fn native_model_decode_body(data: Vec<u8>, id: u32) -> std::result::Result<Self, native_model::DecodeBodyError> {
|
||||
println!("id: {}, {}", id, #id);
|
||||
if id != #id {
|
||||
return Err(native_model::DecodeBodyError::MismatchedModelId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user