Skip to main content

rusteal_core/
lib.rs

1#![allow(clippy::missing_safety_doc)]
2
3pub mod api;
4pub mod error;
5pub mod traits;
6
7#[allow(unused_imports, unused_unsafe, unsafe_op_in_unsafe_fn, clippy::all)]
8pub mod ffi_dispatch {
9    include!(concat!(env!("OUT_DIR"), "/ffi_dispatch.rs"));
10}
11pub mod console;
12pub mod containers;
13pub mod delegate_registry;
14pub mod dynamic_call;
15pub mod ffi_guard;
16pub mod fname;
17pub mod input;
18pub mod logging;
19pub mod object_ref;
20pub mod pinned;
21pub mod reify_registry;
22pub mod soft_ref;
23pub mod struct_ref;
24pub mod subclass_of;
25pub mod task;
26pub mod ue_math;
27pub mod weak_ptr;
28pub mod widget;
29pub mod world;
30
31pub use api::{api, init_api};
32pub use console::ConsoleVariable;
33pub use containers::{ContainerElement, OwnedStruct, UeArray, UeMap, UeSet};
34pub use delegate_registry::DelegateBinding;
35pub use dynamic_call::{DynamicCall, DynamicCallResult};
36pub use error::{
37    RustealError, RustealResult, check_ffi, check_ffi_ctx, ffi_infallible, ffi_infallible_ctx,
38};
39pub use ffi_guard::ffi_boundary;
40pub use logging::{LOG_DISPLAY, LOG_ERROR, LOG_WARNING};
41pub use object_ref::{Checked, ObjectPointer, UObjectRef};
42pub use pinned::Pinned;
43pub use soft_ref::SoftObjectRef;
44pub use struct_ref::UStructRef;
45pub use subclass_of::SubclassOf;
46pub use traits::{HasParent, Inherits, UeClass, UeEnum, UeHandle, UeStruct, ValidHandle};
47
48pub use fname::FName;
49pub use struct_ref::{OutRef, out_ref_from_param, struct_ref_from_param};
50pub use ue_math::{
51    BoxSphereBounds, Color, LinearColor, Plane, Ray, Rotator, Sphere, Transform, UeBox, UeBox2d,
52};
53pub use weak_ptr::TWeakObjectPtr;
54
55pub use rusteal_ffi::{
56    FNameHandle, FPropertyHandle, FWeakObjectHandle, RustealErrorCode, UClassHandle, UObjectHandle,
57    UStructHandle,
58};
59
60use std::sync::{Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
61
62pub(crate) fn lock_or_recover<T>(m: &Mutex<T>) -> MutexGuard<'_, T> {
63    m.lock().unwrap_or_else(|e| e.into_inner())
64}
65
66pub(crate) fn read_or_recover<T>(m: &RwLock<T>) -> RwLockReadGuard<'_, T> {
67    m.read().unwrap_or_else(|e| e.into_inner())
68}
69
70pub(crate) fn write_or_recover<T>(m: &RwLock<T>) -> RwLockWriteGuard<'_, T> {
71    m.write().unwrap_or_else(|e| e.into_inner())
72}