Skip to main content

Module flags

Module flags 

Source
Expand description

The registry: defining flags, checking them, and overriding the answer.

use rustlavel_flags::{Flags, Scope};

let flags = Flags::new()
    .define("new-checkout", |scope| async move { scope.id().ends_with('7') })
    .define("beta-search", |_| async { false })
    .rollout("dark-mode", 25);

assert!(flags.active("new-checkout", &Scope::user_id(17)).await.unwrap());
assert!(flags.inactive("beta-search", &Scope::user_id(17)).await.unwrap());

// ...except for this one customer, who asked.
flags.activate_for("beta-search", &Scope::user_id(17)).await.unwrap();
assert!(flags.active("beta-search", &Scope::user_id(17)).await.unwrap());

Structs§

Flags
Every flag the application knows about, and the store behind them.
ScopedFlags
Flags fixed on one scope, remembering what it has already resolved.

Traits§

FlagAnswer
What a resolver may return.