summaryrefslogtreecommitdiff
path: root/rust/src/types
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/types')
-rw-r--r--rust/src/types/structure.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/rust/src/types/structure.rs b/rust/src/types/structure.rs
index 7de466a4..3b609287 100644
--- a/rust/src/types/structure.rs
+++ b/rust/src/types/structure.rs
@@ -571,6 +571,16 @@ impl StructureMember {
pub fn bit_offset(&self) -> u64 {
(self.offset * 8) + self.bit_position.unwrap_or(0) as u64
}
+
+ /// Member width in bits.
+ ///
+ /// NOTE: This is a helper to calculate the bit width of the member, even for non-bitfield members.
+ /// This is not to be confused with the field `bit_width`, which is set for only bitfield members.
+ pub fn width_in_bits(&self) -> u64 {
+ self.bit_width
+ .map(|w| w as u64)
+ .unwrap_or(self.ty.contents.width() * 8)
+ }
}
impl CoreArrayProvider for StructureMember {