Line data Source code
1 : use lief_ffi as ffi;
2 :
3 : use crate::pdb::types::PdbType;
4 : use crate::{
5 : common::{into_optional, FromFFI},
6 : pdb::Type,
7 : };
8 : use std::marker::PhantomData;
9 :
10 : /// This structure wraps a `LF_ARRAY` PDB type
11 : pub struct Array<'a> {
12 : ptr: cxx::UniquePtr<ffi::PDB_types_Array>,
13 : _owner: PhantomData<&'a ()>,
14 : }
15 :
16 : impl FromFFI<ffi::PDB_types_Array> for Array<'_> {
17 0 : fn from_ffi(cmd: cxx::UniquePtr<ffi::PDB_types_Array>) -> Self {
18 0 : Self {
19 0 : ptr: cmd,
20 0 : _owner: PhantomData,
21 0 : }
22 0 : }
23 : }
24 :
25 : impl Array<'_> {
26 : /// The number of element in this array
27 0 : pub fn numberof_elements(&self) -> u64 {
28 0 : self.ptr.numberof_elements()
29 0 : }
30 :
31 : /// Type of the elements
32 0 : pub fn element_type(&self) -> Option<Type<'_>> {
33 0 : into_optional(self.ptr.element_type())
34 0 : }
35 :
36 : /// Type of the index
37 0 : pub fn index_type(&self) -> Option<Type<'_>> {
38 0 : into_optional(self.ptr.index_type())
39 0 : }
40 : }
41 :
42 : impl PdbType for Array<'_> {
43 0 : fn get_base(&self) -> &ffi::PDB_Type {
44 0 : self.ptr.as_ref().unwrap().as_ref()
45 0 : }
46 : }
|