diff options
| author | Josh Ferrell <josh@vector35.com> | 2026-01-13 12:54:06 -0500 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2026-01-13 12:54:38 -0500 |
| commit | c68f8d48afb9b3e6cdac363c8a578a051ad6e21d (patch) | |
| tree | 33938d0c6c634426a177c5987c3e861d2237242e /rust/src/binary_view.rs | |
| parent | 56b23981c1149a2b2dece05a2eaefb0787f34e15 (diff) | |
[Rust API] Add BinaryViewExt::{tags_all_scopes, tag_types, tags_by_type}
Diffstat (limited to 'rust/src/binary_view.rs')
| -rw-r--r-- | rust/src/binary_view.rs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/rust/src/binary_view.rs b/rust/src/binary_view.rs index 30733516..8309d15d 100644 --- a/rust/src/binary_view.rs +++ b/rust/src/binary_view.rs @@ -54,7 +54,7 @@ use crate::segment::{Segment, SegmentBuilder}; use crate::settings::Settings; use crate::string::*; use crate::symbol::{Symbol, SymbolType}; -use crate::tags::{Tag, TagType}; +use crate::tags::{Tag, TagReference, TagType}; use crate::types::{ NamedTypeReference, QualifiedName, QualifiedNameAndType, QualifiedNameTypeAndId, Type, TypeArchive, TypeArchiveId, TypeContainer, TypeLibrary, @@ -1646,6 +1646,34 @@ pub trait BinaryViewExt: BinaryViewBase { } } + /// Get all tags in all scopes + fn tags_all_scopes(&self) -> Array<TagReference> { + let mut count = 0; + unsafe { + let tag_references = BNGetAllTagReferences(self.as_ref().handle, &mut count); + Array::new(tag_references, count, ()) + } + } + + /// Get all tag types present for the view + fn tag_types(&self) -> Array<TagType> { + let mut count = 0; + unsafe { + let tag_types_raw = BNGetTagTypes(self.as_ref().handle, &mut count); + Array::new(tag_types_raw, count, ()) + } + } + + // Get all tags of a specific type + fn tags_by_type(&self, tag_type: &TagType) -> Array<TagReference> { + let mut count = 0; + unsafe { + let tag_references = + BNGetAllTagReferencesOfType(self.as_ref().handle, tag_type.handle, &mut count); + Array::new(tag_references, count, ()) + } + } + /// Get a tag by its id. /// /// Note this does not tell you anything about where it is used. |
