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