recoverable_spawn/thread/
type.rs

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