pub enum RustField {
Member(usize),
Bits {
name: String,
offset: u64,
bytes: u64,
},
Pad {
name: String,
bytes: u64,
},
Align {
name: String,
align: u64,
},
}Expand description
One field of the generated Rust item.
A record without bit-fields maps one C member onto one Rust field, and this
is simply its member list. Bit-fields break that correspondence: they share
storage, they may be unnamed, and the bytes they occupy do not always start
where #[repr(C)] would put the next field on its own.
Variants§
Member(usize)
A C member, by its index in RecordDef::fields.
Bits
The bytes one maximal run of bit-fields lives in.
Fields
Pad
Filler that puts the field after it where C puts it.
Align
A zero-sized field whose only job is to raise the item’s alignment.
#[repr(C, align(N))] says the same thing and reads better, so it is
what a record normally carries. A record that is a member of a packed
one cannot use it: Rust refuses a packed type that transitively holds a
#[repr(align)] one (E0588), while C is perfectly happy to pack such
a member. A [uN; 0] field costs no bytes, raises the alignment the
same way, and is not a repr(align) type.