soph_core/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
pub mod error;
pub mod support;
pub mod traits;

cfg_if::cfg_if! {
    if #[cfg(feature = "eyre")]{
        pub type AnyError = eyre::Report;
    }else if #[cfg(feature = "anyhow")]{
        pub type AnyError = anyhow::Error;
    }else{
        pub type AnyError = BoxError;
    }
}

pub type BoxError = Box<dyn std::error::Error + Send + Sync>;

pub type BoxFuture<'a, T = ()> =
    std::pin::Pin<Box<dyn std::future::Future<Output = T> + Send + 'a>>;

pub type BoxClosure<T = ()> = Box<dyn Fn() -> T + Send + Sync>;

pub type BoxCallback<P = (), R = ()> = Box<dyn Fn(P) -> R + Send + Sync>;

pub type Closure<T = ()> = std::sync::Arc<dyn Fn() -> T + Send + Sync>;

pub type Callback<P = (), R = ()> = std::sync::Arc<dyn Fn(P) -> R + Send + Sync>;

pub type Instance = std::sync::Arc<dyn std::any::Any + Send + Sync>;

pub type Result<T, E = AnyError> = std::result::Result<T, E>;

pub type SharedString = std::borrow::Cow<'static, str>;

// re-export
pub use async_trait::async_trait;
pub use cfg_if::cfg_if;