brec_macros 0.4.0

Code generator for brec. Implements the block and payload macros.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::Ident;

use crate::*;

impl FromBytes for BlockField {
    fn safe(&self, src: &Ident, from: usize, to: usize) -> TokenStream {
        let name = format_ident!("{}", self.name);
        let ty = self.ty.safe(src, from, to);
        quote! {
            let #name = #ty;
        }
    }
}