diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-09-16 16:09:01 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-09-29 21:02:23 -0400 |
| commit | 37e078eb3ebf5393d3bdad7f8014e83d654f9857 (patch) | |
| tree | 7494ba7183fb42688d92d8ae3b67ec7ecc01fce3 /rust/src/binaryview.rs | |
| parent | 273f6c483d7e36aa00287cf212990d54730c1845 (diff) | |
[Rust API] BinaryView metadata storing
Diffstat (limited to 'rust/src/binaryview.rs')
| -rw-r--r-- | rust/src/binaryview.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs index ff556d54..c60c8808 100644 --- a/rust/src/binaryview.rs +++ b/rust/src/binaryview.rs @@ -860,6 +860,21 @@ pub trait BinaryViewExt: BinaryViewBase { .map(|md| T::try_from(md.as_ref()).map_err(|_| ())) } + fn store_metadata<V, S: BnStrCompatible>(&self, key: S, value: V, is_auto: bool) + where + V: Into<Ref<Metadata>>, + { + let md = value.into(); + unsafe { + BNBinaryViewStoreMetadata( + self.as_ref().handle, + key.into_bytes_with_nul().as_ref().as_ptr() as *const c_char, + md.as_ref().handle, + is_auto, + ) + }; + } + fn remove_metadata<S: BnStrCompatible>(&self, key: S) { unsafe { BNBinaryViewRemoveMetadata( |
