featureflag/lib.rs
1//! Feature flagging facade for Rust.
2//!
3//! This library provides a flexible and extensible way to control feature flags
4//! in Rust applications.
5//!
6//! The core trait of this library is the [`Evaluator`], which is used to evaluate
7//! feature flags at runtime.
8//!
9//! The [`context!`] macro and [`Context`] type can be in evaluators to provide
10//! contextual information for feature flag evaluation, such as user ID and session ID.
11//!
12//! The [`is_enabled!`] macro is the primary way to check if a feature is enabled.
13//! This macro takes a feature name and a default value, and returns a boolean
14//! indicating whether the feature is enabled or not. Alternatively, the [`feature!`]
15//! macro can be used to store a [`Feature`] is a variable or constant, or the
16//! [`Feature::new`] or [`Feature::new_with_default_fn`] methods can be used
17//! directly to create new feature flags at runtime.
18#![cfg_attr(docsrs, feature(doc_cfg))]
19
20pub mod context;
21pub mod evaluator;
22pub mod extensions;
23pub mod feature;
24pub mod fields;
25pub mod utils;
26pub mod value;
27
28pub use crate::{
29 context::Context,
30 evaluator::{Evaluator, set_global_default, try_set_global_default},
31 feature::Feature,
32};
33
34#[doc(hidden)]
35pub mod __reexport {
36
37 #[cfg(feature = "feature-registry")]
38 pub use inventory;
39}