pub struct FeatureFlagsPlugin { /* private fields */ }Expand description
Feature flags plugin. Toggle features per user/percentage.
Implementations§
Source§impl FeatureFlagsPlugin
impl FeatureFlagsPlugin
pub fn new() -> Self
Sourcepub fn add_boolean(&self, name: &str, description: &str, enabled: bool)
pub fn add_boolean(&self, name: &str, description: &str, enabled: bool)
Define a flag that’s globally on or off.
Sourcepub fn add_user_list(&self, name: &str, description: &str, users: Vec<String>)
pub fn add_user_list(&self, name: &str, description: &str, users: Vec<String>)
Define a flag that’s on for specific users.
Sourcepub fn add_percentage(&self, name: &str, description: &str, percent: u8)
pub fn add_percentage(&self, name: &str, description: &str, percent: u8)
Define a flag that’s on for a percentage of users.
Sourcepub fn is_enabled(&self, flag_name: &str, auth: &AuthContext) -> bool
pub fn is_enabled(&self, flag_name: &str, auth: &AuthContext) -> bool
Check if a flag is enabled for a given auth context.
Sourcepub fn set_enabled(&self, flag_name: &str, enabled: bool) -> bool
pub fn set_enabled(&self, flag_name: &str, enabled: bool) -> bool
Toggle a flag on or off.
Sourcepub fn list_flags(&self) -> Vec<FeatureFlag>
pub fn list_flags(&self) -> Vec<FeatureFlag>
List all flags.
Trait Implementations§
Source§impl Plugin for FeatureFlagsPlugin
impl Plugin for FeatureFlagsPlugin
Source§fn on_init(&self, _ctx: &PluginContext)
fn on_init(&self, _ctx: &PluginContext)
Called once when the plugin is registered.
Source§fn routes(&self) -> Vec<PluginRoute>
fn routes(&self) -> Vec<PluginRoute>
Custom API routes this plugin handles.
Source§fn before_insert(
&self,
_entity: &str,
_data: &mut Value,
_auth: &AuthContext,
) -> Result<(), PluginError>
fn before_insert( &self, _entity: &str, _data: &mut Value, _auth: &AuthContext, ) -> Result<(), PluginError>
Called before an entity insert. Return Err to reject.
Source§fn after_insert(
&self,
_entity: &str,
_id: &str,
_data: &Value,
_auth: &AuthContext,
)
fn after_insert( &self, _entity: &str, _id: &str, _data: &Value, _auth: &AuthContext, )
Called after a successful insert.
Source§fn before_update(
&self,
_entity: &str,
_id: &str,
_data: &mut Value,
_auth: &AuthContext,
) -> Result<(), PluginError>
fn before_update( &self, _entity: &str, _id: &str, _data: &mut Value, _auth: &AuthContext, ) -> Result<(), PluginError>
Called before an entity update. Return Err to reject.
Source§fn after_update(
&self,
_entity: &str,
_id: &str,
_data: &Value,
_auth: &AuthContext,
)
fn after_update( &self, _entity: &str, _id: &str, _data: &Value, _auth: &AuthContext, )
Called after a successful update.
Source§fn before_delete(
&self,
_entity: &str,
_id: &str,
_auth: &AuthContext,
) -> Result<(), PluginError>
fn before_delete( &self, _entity: &str, _id: &str, _auth: &AuthContext, ) -> Result<(), PluginError>
Called before an entity delete. Return Err to reject.
Source§fn after_delete(&self, _entity: &str, _id: &str, _auth: &AuthContext)
fn after_delete(&self, _entity: &str, _id: &str, _auth: &AuthContext)
Called after a successful delete.
Source§fn on_request(
&self,
_method: &str,
_path: &str,
_auth: &AuthContext,
) -> Result<(), PluginError>
fn on_request( &self, _method: &str, _path: &str, _auth: &AuthContext, ) -> Result<(), PluginError>
Called on every incoming request (middleware).
Source§fn on_request_with_meta(
&self,
method: &str,
path: &str,
auth: &AuthContext,
_meta: &RequestMeta<'_>,
) -> Result<(), PluginError>
fn on_request_with_meta( &self, method: &str, path: &str, auth: &AuthContext, _meta: &RequestMeta<'_>, ) -> Result<(), PluginError>
Richer variant of [
on_request] that also receives per-request
metadata (peer IP today; more fields may be added later). The
default implementation delegates to on_request so existing
plugins keep working without changes. Plugins that care about
IP — notably rate limiting — override this hook.Source§fn on_session_create(&self, _user_id: &str, _token: &str)
fn on_session_create(&self, _user_id: &str, _token: &str)
Called when a new session is created.
Source§fn entities(&self) -> Vec<ManifestEntity>
fn entities(&self) -> Vec<ManifestEntity>
Additional manifest entities this plugin contributes.
Auto Trait Implementations§
impl !Freeze for FeatureFlagsPlugin
impl RefUnwindSafe for FeatureFlagsPlugin
impl Send for FeatureFlagsPlugin
impl Sync for FeatureFlagsPlugin
impl Unpin for FeatureFlagsPlugin
impl UnsafeUnpin for FeatureFlagsPlugin
impl UnwindSafe for FeatureFlagsPlugin
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