Skip to main content

OrgControlsAccessor

Trait OrgControlsAccessor 

Source
pub trait OrgControlsAccessor: Send + Sync {
    // Required methods
    fn load_org_config<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        org_id: &'life1 str,
        workspace_id: Option<&'life2 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<OrgAiControlsConfig>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn check_budget<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        org_id: &'life1 str,
        workspace_id: Option<&'life2 str>,
        estimated_tokens: u64,
    ) -> Pin<Box<dyn Future<Output = Result<BudgetCheckResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn check_rate_limit<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        org_id: &'life1 str,
        workspace_id: Option<&'life2 str>,
    ) -> Pin<Box<dyn Future<Output = Result<RateLimitCheckResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn is_feature_enabled<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        org_id: &'life1 str,
        workspace_id: Option<&'life2 str>,
        feature: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn record_usage<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        org_id: &'life1 str,
        workspace_id: Option<&'life2 str>,
        user_id: Option<&'life3 str>,
        feature: AiFeature,
        tokens: u64,
        cost_usd: f64,
        metadata: Option<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Trait for accessing org controls from database

Required Methods§

Source

fn load_org_config<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, org_id: &'life1 str, workspace_id: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Option<OrgAiControlsConfig>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Load org controls configuration

Source

fn check_budget<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, org_id: &'life1 str, workspace_id: Option<&'life2 str>, estimated_tokens: u64, ) -> Pin<Box<dyn Future<Output = Result<BudgetCheckResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if budget allows the request

Source

fn check_rate_limit<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, org_id: &'life1 str, workspace_id: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<RateLimitCheckResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if rate limit allows the request

Source

fn is_feature_enabled<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, org_id: &'life1 str, workspace_id: Option<&'life2 str>, feature: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Check if a feature is enabled

Source

fn record_usage<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, org_id: &'life1 str, workspace_id: Option<&'life2 str>, user_id: Option<&'life3 str>, feature: AiFeature, tokens: u64, cost_usd: f64, metadata: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Record usage for audit

Implementors§