diff options
| author | Mason Reed <mason@vector35.com> | 2025-12-11 14:45:23 -0500 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-12-15 19:29:56 -0500 |
| commit | ca0e32efb1e5b9eba157e9fd2eef178d9367c578 (patch) | |
| tree | 12f9eab134807a4b2821e04ada4795e6611ea45f /rust/src/component.rs | |
| parent | a83f2082799695b85b732987adb21112d042b152 (diff) | |
[Rust] Restructure type APIs into `types` module
This helps with documentation, giving a single module for those working with types to find related APIs
Also split out enumeration and structure APIs into their own file, since they have their own backing data separate from `Type`.
Diffstat (limited to 'rust/src/component.rs')
| -rw-r--r-- | rust/src/component.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/rust/src/component.rs b/rust/src/component.rs index 4c5d5992..f038d5c3 100644 --- a/rust/src/component.rs +++ b/rust/src/component.rs @@ -2,7 +2,7 @@ use crate::binary_view::{BinaryView, BinaryViewExt}; use crate::function::Function; use crate::rc::{Array, CoreArrayProvider, CoreArrayProviderInner, Guard, Ref, RefCountable}; use crate::string::{BnString, IntoCStr}; -use crate::types::ComponentReferencedType; +use crate::types::Type; use std::ffi::c_char; use std::fmt::Debug; use std::ptr::NonNull; @@ -304,3 +304,24 @@ unsafe impl CoreArrayProviderInner for Component { Guard::new(Self::from_raw(raw_ptr), context) } } + +// TODO: Remove this struct, or make it not a ZST with a terrible array provider. +/// ZST used only for `Array<ComponentReferencedType>`. +pub struct ComponentReferencedType; + +impl CoreArrayProvider for ComponentReferencedType { + type Raw = *mut BNType; + type Context = (); + type Wrapped<'a> = &'a Type; +} + +unsafe impl CoreArrayProviderInner for ComponentReferencedType { + unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { + BNComponentFreeReferencedTypes(raw, count) + } + + unsafe fn wrap_raw<'a>(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped<'a> { + // SAFETY: &*mut BNType == &Type (*mut BNType == Type) + std::mem::transmute(raw) + } +} |
