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    ErrorContext, ErrorKind, RustealError, RustealResult, UeSubject, check_ffi, check_ffi_ctx,
38    ffi_infallible, ffi_infallible_ctx,
39};
40pub use ffi_guard::ffi_boundary;
41pub use logging::{LOG_DISPLAY, LOG_ERROR, LOG_WARNING};
42pub use object_ref::{Checked, ObjectPointer, UObjectRef};
43pub use pinned::Pinned;
44pub use soft_ref::SoftObjectRef;
45pub use struct_ref::UStructRef;
46pub use subclass_of::SubclassOf;
47pub use traits::{HasParent, Inherits, UeClass, UeEnum, UeHandle, UeStruct, ValidHandle};
48
49pub use fname::FName;
50pub use struct_ref::{OutRef, out_ref_from_param, struct_ref_from_param};
51pub use ue_math::{
52    BoxSphereBounds, Color, LinearColor, Plane, Ray, Rotator, Sphere, Transform, UeBox, UeBox2d,
53};
54pub use weak_ptr::TWeakObjectPtr;
55
56pub use rusteal_ffi::{
57    FNameHandle, FPropertyHandle, FWeakObjectHandle, RustealErrorCode, UClassHandle, UObjectHandle,
58    UStructHandle,
59};
60
61use std::sync::{Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
62
63pub(crate) fn lock_or_recover<T>(m: &Mutex<T>) -> MutexGuard<'_, T> {
64    m.lock().unwrap_or_else(|e| e.into_inner())
65}
66
67pub(crate) fn read_or_recover<T>(m: &RwLock<T>) -> RwLockReadGuard<'_, T> {
68    m.read().unwrap_or_else(|e| e.into_inner())
69}
70
71pub(crate) fn write_or_recover<T>(m: &RwLock<T>) -> RwLockWriteGuard<'_, T> {
72    m.write().unwrap_or_else(|e| e.into_inner())
73}