pub struct FeatureContext { /* private fields */ }Expand description
Application context passed to feature flag evaluation.
Contains arbitrary key-value data used to evaluate feature flag conditions. The identity fields determine which fields are used for rollout bucketing.
Implementations§
Source§impl FeatureContext
impl FeatureContext
pub fn new() -> Self
Sourcepub fn identity_fields(&mut self, fields: Vec<&str>)
pub fn identity_fields(&mut self, fields: Vec<&str>)
Set the fields used to compute this context’s rollout identity.
Fields are sorted lexicographically before hashing. Calling this resets the cached identity value.
Sourcepub fn insert(&mut self, key: &str, value: impl Into<Value>)
pub fn insert(&mut self, key: &str, value: impl Into<Value>)
Insert a key-value pair into the context.
Sourcepub fn id(&self) -> u64
pub fn id(&self) -> u64
Compute and return this context’s rollout identity.
The result is cached and reset when identity fields or context data change. When no identity fields are set, all context keys are used (non-deterministic rollout across contexts with different keys). The id value is mostly used to id % 100 < rollout.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FeatureContext
impl !RefUnwindSafe for FeatureContext
impl Send for FeatureContext
impl !Sync for FeatureContext
impl Unpin for FeatureContext
impl UnsafeUnpin for FeatureContext
impl UnwindSafe for FeatureContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more