recoverable_spawn/thread/
type.rs

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