1use std::{ffi::c_void, sync::Arc};
2
3use crate::{
4 bindings::{mono_assembly_get_image, MonoAssembly},
5 domain::Domain,
6 image::Image,
7 void::AsRawVoid,
8 MonoResult,
9};
10
11#[derive(Clone, Debug)]
12pub struct Assembly {
13 pub mono_ptr: *mut MonoAssembly,
14 pub domain: Arc<Domain>,
15}
16
17impl Assembly {
18 pub fn get_image(&self) -> MonoResult<Image> {
19 let mono_ptr = unsafe { mono_assembly_get_image(self.mono_ptr) };
20
21 if mono_ptr.is_null() {
22 return Err("MonoImage Null Error!".into());
23 }
24
25 Ok(Image {
26 mono_ptr,
27 assembly: Arc::new(self.clone()),
28 domain: self.domain.clone(),
29 })
30 }
31}
32
33impl AsRawVoid for Assembly {
34 fn as_raw_void(self) -> *mut c_void {
35 self.mono_ptr as *mut c_void
36 }
37}