Skip to main content

rusteal_ffi/
callbacks.rs

1use crate::handles::UObjectHandle;
2
3/// Callback table filled by Rust and returned to C++ from `rusteal_init`.
4/// C++ calls into Rust through these function pointers.
5#[repr(C)]
6pub struct RustealRustCallbacks {
7    /// Called when a Rust-defined UClass instance is destroyed (reify only).
8    pub drop_rust_instance: extern "C" fn(
9        handle: UObjectHandle,
10        type_id: u64,
11        rust_data: *mut u8,
12    ),
13
14    /// UE → Rust function call forwarding (for Rust-defined UFunctions).
15    pub invoke_rust_function: extern "C" fn(
16        callback_id: u64,
17        obj: UObjectHandle,
18        params: *mut u8,
19    ),
20
21    /// Delegate callback forwarding.
22    pub invoke_delegate_callback: extern "C" fn(callback_id: u64, params: *mut u8),
23
24    /// Shutdown notification — Rust should release all resources.
25    pub on_shutdown: extern "C" fn(),
26
27    /// Called by C++ when a reified class instance is constructed.
28    pub construct_rust_instance: extern "C" fn(
29        obj: UObjectHandle,
30        type_id: u64,
31        is_cdo: bool,
32    ),
33
34    /// Called by C++ when a Pinned object is destroyed (DestroyActor, level unload, etc.).
35    pub notify_pinned_destroyed: extern "C" fn(handle: UObjectHandle),
36}