thread_panic_restart/thread/type.rs
1use crate::*;
2use std::{any::Any, sync::Arc};
3
4/// Type alias for a boxed dynamic type that implements `Any` and `Send`.
5///
6/// - Represents a boxed value that can be used for dynamic type checking (`Any`)
7/// and safely transferred across threads (`Send`).
8pub type BoxAnySend = Box<dyn Any + Send>;
9
10/// Type alias for the result type returned by spawnable functions.
11///
12/// - `Ok(())`: Indicates successful execution of the function.
13/// - `Err(BoxAnySend)`: Contains a boxed error value in case of a panic or failure.
14pub type SpawnResult = Result<(), BoxAnySend>;
15
16/// Alias for an `Arc`-wrapped recoverable function.
17///
18/// - This type represents an `Arc`-wrapped version of any function implementing the `RecoverableFunction` trait.
19/// - Enables shared ownership and thread-safe usage of recoverable functions in concurrent environments.
20pub type ArcRecoverableFunction = Arc<dyn RecoverableFunction>;
21
22/// Alias for an `Arc`-wrapped error handler function.
23///
24/// - This type represents an `Arc`-wrapped version of any function implementing the `ErrorHandlerFunction` trait.
25/// - Allows shared ownership and thread-safe handling of errors with custom logic across multiple threads.
26pub type ArcErrorHandlerFunction = Arc<dyn ErrorHandlerFunction>;