I'm trying to create an EthernetFrame
struct. In C I could use the flexible array member as the last field in the struct. How do I do this in Rust? Also how do I create an instance of this struct from the Vec<u8>
buffer I have? (Since pointer casting only works on primitive types in rust.)
The total size of the Payload
can vary between 50 bytes to 1504 bytes.
#[repr(C, packed)]
pub struct EthernetFrame {
dst: [u8;6],
src: [u8;6],
ether_type: [u8;2],
payload: <dynamically sized u8 array>,
}