Crates.io | overlay_macro |
lib.rs | overlay_macro |
version | 2.0.0 |
source | src |
created_at | 2024-05-30 17:16:41.451808 |
updated_at | 2024-07-03 17:40:08.282696 |
description | A proc-macro for implementing Overlay, to reinterpret a slice of bytes as a bit/byte packed struct |
homepage | https://github.com/bobrippling/overlay-rs |
repository | https://github.com/bobrippling/overlay-rs |
max_upload_size | |
id | 1257086 |
size | 32,640 |
A proc-macro for generating a struct which can be overlaid. See the documentation for usage and examples.
#[overlay]
#[derive(Clone, Debug)]
pub struct InquiryCommand {
#[overlay(byte=0, bits=0..8)]
pub op_code: u8,
#[overlay(byte=1)]
pub enable_vital_product_data: bool,
#[overlay(byte=2, bits=0..=7)]
pub page_code: u8,
#[overlay(bytes=3..=4, bits=0..=7)]
pub allocation_length: u16,
...
}
This will create a wrapper struct around an array of bytes, with generated getters and setters for each "field", accessing the bytes/bits at the given offsets.
u32
?compile_error!()
/ remove unwrap
/ expect
syn
2.0