options/
lib.rs

1#![doc = include_str!("../README.md")]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3
4/// Represents the type alias for an options reference.
5#[cfg(not(all(feature = "di", feature = "async")))]
6pub type Ref<T> = std::rc::Rc<T>;
7
8/// Represents the type alias for an options reference.
9#[cfg(all(not(feature = "di"), feature = "async"))]
10pub type Ref<T> = std::sync::Arc<T>;
11
12/// Represents the type alias for an options reference.
13#[cfg(all(feature = "di", feature = "async"))]
14pub type Ref<T> = di::Ref<T>;
15
16// trait aliases are unstable so define a custom
17// marker that can bridge the gap
18//
19// REF: https://github.com/rust-lang/rust/issues/41517
20
21#[cfg(not(feature = "async"))]
22pub trait Value: Sized {}
23
24#[cfg(not(feature = "async"))]
25impl<T> Value for T {}
26
27#[cfg(feature = "async")]
28pub trait Value: Sized + Send + Sync {}
29
30#[cfg(feature = "async")]
31impl<T: Send + Sync> Value for T {}
32
33mod cache;
34mod configure;
35mod factory;
36mod manager;
37mod monitor;
38mod option;
39mod snapshot;
40mod token;
41mod validate;
42
43#[cfg(feature = "di")]
44mod di_ext;
45
46#[cfg(feature = "di")]
47mod builder;
48
49#[cfg(feature = "cfg")]
50mod cfg_ext;
51
52pub use cache::*;
53pub use configure::*;
54pub use factory::*;
55pub use manager::*;
56pub use monitor::*;
57pub use option::*;
58pub use snapshot::*;
59pub use token::*;
60pub use validate::*;
61
62#[cfg(feature = "di")]
63#[cfg_attr(docsrs, doc(cfg(feature = "di")))]
64pub use builder::*;
65
66/// Contains options extension methods.
67#[cfg(any(feature = "di", feature = "cfg"))]
68pub mod ext {
69    use super::*;
70    
71    #[cfg(feature = "di")]
72    #[cfg_attr(docsrs, doc(cfg(feature = "di")))]
73    pub use di_ext::*;
74
75    #[cfg(feature = "cfg")]
76    #[cfg_attr(docsrs, doc(cfg(feature = "cfg")))]
77    pub use cfg_ext::*;
78}