diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-07-21 17:49:19 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-09-29 21:02:22 -0400 |
| commit | 1f2dc817cf30e41ed925248a76a217673a90b0cb (patch) | |
| tree | f471c9820804a281e3556ab7b2c0200ddedbbcba /rust/src | |
| parent | d552ae9beae6404c13548b98ec7a7ec4e6b3dd90 (diff) | |
[Rust API] Debug for StructureBuilder
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/types.rs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/rust/src/types.rs b/rust/src/types.rs index 90abeb41..746142a5 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -1460,6 +1460,22 @@ impl StructureBuilder { self } + pub fn set_alignment<'a>(&'a mut self, alignment: usize) -> &'a mut Self { + unsafe { + BNSetStructureBuilderAlignment(self.handle, alignment); + } + + self + } + + pub fn set_packed<'a>(&'a mut self, packed: bool) -> &'a mut Self { + unsafe { + BNSetStructureBuilderPacked(self.handle, packed); + } + + self + } + pub fn append<'a, 'b, S: BnStrCompatible, T: Into<Conf<&'b Type>>>( &'a mut self, t: T, @@ -1534,11 +1550,19 @@ impl StructureBuilder { unsafe { BNGetStructureBuilderWidth(self.handle) } } + pub fn alignment(&self) -> usize { + unsafe { BNGetStructureBuilderAlignment(self.handle) } + } + + pub fn packed(&self) -> bool { + unsafe { BNIsStructureBuilderPacked(self.handle) } + } + pub fn structure_type(&self) -> StructureType { unsafe { BNGetStructureBuilderType(self.handle) } } - // TODO : The other methods in the python version (alignment, packed, type, members, remove, replace, etc) + // TODO : The other methods in the python version (type, members, remove, replace, etc) } impl From<&Structure> for StructureBuilder { @@ -1547,6 +1571,12 @@ impl From<&Structure> for StructureBuilder { } } +impl Debug for StructureBuilder { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "StructureBuilder {{ ... }}") + } +} + impl Drop for StructureBuilder { fn drop(&mut self) { unsafe { BNFreeStructureBuilder(self.handle) }; |
