Skip to main content

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(any(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(feature = "di")]
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 snapshot;
39mod token;
40
41/// Provides options validation.
42pub mod validation;
43
44/// Contains the library prelude.
45#[cfg(any(feature = "di", feature = "cfg"))]
46pub mod prelude;
47
48pub use cache::Cache;
49pub use configure::{Configure, PostConfigure};
50pub use factory::{DefaultFactory, Factory};
51pub use manager::Manager;
52pub use monitor::{DefaultMonitor, Monitor, Subscription};
53pub use snapshot::Snapshot;
54pub use token::ChangeTokenSource;