use crate::injector_core::common::FuncPtrInternal;
use std::any::TypeId;
use std::ptr::NonNull;
pub struct FuncPtr {
pub(super) func_ptr_internal: FuncPtrInternal,
pub(super) signature: &'static str,
pub(super) type_id: Option<TypeId>,
}
impl FuncPtr {
pub unsafe fn new(ptr: *const (), signature: &'static str) -> Self {
let p = ptr as *mut ();
let nn = NonNull::new(p).expect("Pointer must not be null");
Self {
func_ptr_internal: FuncPtrInternal::new(nn),
signature,
type_id: None,
}
}
pub unsafe fn new_with_type_id(
ptr: *const (),
signature: &'static str,
type_id: TypeId,
) -> Self {
let p = ptr as *mut ();
let nn = NonNull::new(p).expect("Pointer must not be null");
Self {
func_ptr_internal: FuncPtrInternal::new(nn),
signature,
type_id: Some(type_id),
}
}
}