pub trait FlagsExt {
// Required methods
fn flags(&self) -> Result<Flags>;
fn flag_scope(&self) -> Scope;
fn scoped_flags(&self) -> Result<ScopedFlags>;
fn flag(&self, flag: &str) -> impl Future<Output = Result<bool>> + Send;
fn flag_off(&self, flag: &str) -> impl Future<Output = Result<bool>> + Send;
}Expand description
req.flag(...) — asking about a flag from inside a handler.
The companion to WhenActive, for when the flag changes the page rather
than removing it: a new panel, a different template, an extra field on a
form.
Every method returns Result, and that is deliberate. “I could not find
out” is a third answer, distinct from on and from off, and collapsing it
into false would turn a store outage into a silent, global rollback that
looks exactly like the flag being off on purpose.
Required Methods§
Sourcefn flag_scope(&self) -> Scope
fn flag_scope(&self) -> Scope
The scope this request is checked as.
The logged-in rustlavel_auth::Identity if there is one — attached by
the auth middleware, or read from the session if only the session
middleware is installed — and Scope::none otherwise. A guest is not
a scope of their own: they are everybody, and giving them one would mean
a percentage rollout that reshuffles on every visit.
Sourcefn scoped_flags(&self) -> Result<ScopedFlags>
fn scoped_flags(&self) -> Result<ScopedFlags>
A ScopedFlags for this request, reusing the one WhenActive
attached if there is one.
Take it once and keep it when a handler checks several flags. Calling
FlagsExt::flag repeatedly on a request that did not come through
WhenActive runs the resolver once per call — the memo lives in the
view, and a fresh view remembers nothing.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".