pub trait FeatureFlag: Send + Sync {
// Required methods
async fn is_enabled(&self, key: &str) -> bool;
async fn is_enabled_for_user(&self, key: &str, user_id: &str) -> bool;
async fn get_variant(&self, key: &str) -> Option<String>;
}Expand description
功能开关 trait (dyn 兼容)
Required Methods§
Sourceasync fn is_enabled(&self, key: &str) -> bool
async fn is_enabled(&self, key: &str) -> bool
检查开关是否启用
Sourceasync fn is_enabled_for_user(&self, key: &str, user_id: &str) -> bool
async fn is_enabled_for_user(&self, key: &str, user_id: &str) -> bool
检查开关是否启用 (带用户上下文)
Sourceasync fn get_variant(&self, key: &str) -> Option<String>
async fn get_variant(&self, key: &str) -> Option<String>
获取开关变体
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.