pub struct DbOrgControls { /* private fields */ }Expand description
Database-backed org controls accessor
Implementations§
Source§impl DbOrgControls
impl DbOrgControls
Sourcepub fn new(pool: Pool<Postgres>) -> DbOrgControls
pub fn new(pool: Pool<Postgres>) -> DbOrgControls
Create a new database-backed org controls accessor
Trait Implementations§
Source§impl OrgControlsAccessor for DbOrgControls
impl OrgControlsAccessor for DbOrgControls
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>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbOrgControls: 'async_trait,
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>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbOrgControls: 'async_trait,
Load org controls configuration from database
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, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbOrgControls: '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, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbOrgControls: '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, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbOrgControls: '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, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbOrgControls: '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, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
DbOrgControls: '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, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
DbOrgControls: '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<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
DbOrgControls: '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<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
DbOrgControls: 'async_trait,
Record usage for audit
Auto Trait Implementations§
impl Freeze for DbOrgControls
impl !RefUnwindSafe for DbOrgControls
impl Send for DbOrgControls
impl Sync for DbOrgControls
impl Unpin for DbOrgControls
impl UnsafeUnpin for DbOrgControls
impl !UnwindSafe for DbOrgControls
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more