add some consts

This commit is contained in:
Jean-Marie Mineau 2023-08-23 12:59:29 +02:00
parent 5dd96fb173
commit d44e2b624b
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
5 changed files with 280 additions and 10 deletions

View file

@ -42,6 +42,10 @@ use syn::{
/// );
/// ```
///
/// ## Enum
///
/// TODO
///
/// ## Prefix and suffix
///
/// To define a constant prefix before a serialised field or suffixe after, use `#[prefix(<prefix>)]`
@ -74,10 +78,12 @@ pub fn derive_serializable(input: proc_macro::TokenStream) -> proc_macro::TokenS
let implem_size = get_implem_size(&input.data, &params);
let expanded = quote! {
impl androscalpel_serializer::Serializable for #name {
#[allow(clippy::single_element_loop)]
fn serialize(&self, output: &mut dyn std::io::Write) -> androscalpel_serializer::Result<()> {
#implem_serialize
}
#[allow(clippy::single_element_loop)]
fn deserialize(input: &mut dyn androscalpel_serializer::ReadSeek) -> androscalpel_serializer::Result<Self> {
#implem_deserialize
}
@ -175,7 +181,7 @@ impl ParamsStruct {
Meta::List(MetaList { path, tokens, .. }) if path.is_ident("prefix_type") => {
params.prefix_type = Some(syn::parse2(tokens.clone()).unwrap());
}
_ => unimplemented!(),
_ => (),
}
}
params
@ -198,7 +204,7 @@ impl ParamsField {
Meta::List(MetaList { path, .. }) if path.is_ident("prefix_type") => {
panic!("Fields cannot take the attribut 'prefix_type'")
}
_ => unimplemented!(),
_ => (),
}
}
params
@ -218,7 +224,7 @@ impl ParamsVariant {
Meta::List(MetaList { path, .. }) if path.is_ident("prefix_type") => {
panic!("Variant cannot take the attribut 'prefix_type'")
}
_ => unimplemented!(),
_ => (),
}
}
params