29 lines
803 B
Rust
29 lines
803 B
Rust
pub use tokio;
|
|
pub use tracing;
|
|
|
|
#[derive(Debug)]
|
|
pub enum PluginError {
|
|
FunctionError(String),
|
|
Other(String),
|
|
}
|
|
|
|
impl core::fmt::Display for PluginError {
|
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
match self {
|
|
PluginError::FunctionError(msg) => write!(f, "Function error: {}", msg),
|
|
PluginError::Other(msg) => write!(f, "Other error: {}", msg),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for PluginError {}
|
|
|
|
//pub type AsyncFnReturnType = Result<(), PluginError>;
|
|
//pub type AsyncFn = Box<
|
|
// dyn Fn()
|
|
// -> std::pin::Pin<Box<dyn std::future::Future<Output = AsyncFnReturnType> + Send + Sync>>
|
|
// + Send
|
|
// + Sync,
|
|
//>;
|
|
pub type AsyncFnReturnType = tokio::task::JoinHandle<Result<(), PluginError>>;
|
|
pub type AsyncFn = Box<dyn Fn() -> AsyncFnReturnType + Send + Sync>;
|