pub struct CreateLimitRequest {
pub user_id: String,
pub project_id: Option<String>,
pub max_tokens_per_day: Option<i64>,
pub max_requests_per_minute: Option<i64>,
pub max_cost_per_month_microdollars: Option<i64>,
}Expand description
Create limit request
Fields§
§user_id: String§project_id: Option<String>§max_tokens_per_day: Option<i64>§max_requests_per_minute: Option<i64>§max_cost_per_month_microdollars: Option<i64>Implementations§
Source§impl CreateLimitRequest
impl CreateLimitRequest
Sourcepub fn validate_values(&self) -> Result<(), ValidationError>
pub fn validate_values(&self) -> Result<(), ValidationError>
Validate field values (returns 400 errors)
Checks that all provided field values are positive and within safe range.
§Errors
Returns error if any provided field is ≤ 0 or exceeds MAX_SAFE_LIMIT
Sourcepub fn validate_presence(&self) -> Result<(), ValidationError>
pub fn validate_presence(&self) -> Result<(), ValidationError>
Validate that at least one field is provided (returns 422 errors)
§Errors
Returns error if all fields are None (no limits specified, semantic error)
Sourcepub fn validate(&self) -> Result<(), ValidationError>
pub fn validate(&self) -> Result<(), ValidationError>
Validate limit creation request
§Rules
- At least one limit must be specified (not all None)
- All specified limits must be positive (> 0)
- All specified limits must be within safe range (≤ MAX_SAFE_LIMIT)
§Returns
- Ok(()) if validation passes
- Err(String) with error message if validation fails
§Errors
Returns descriptive error message for:
- All limits are None (missing required data)
- Any limit is ≤ 0
- Any limit exceeds MAX_SAFE_LIMIT
Trait Implementations§
Source§impl Debug for CreateLimitRequest
impl Debug for CreateLimitRequest
Source§impl<'de> Deserialize<'de> for CreateLimitRequest
impl<'de> Deserialize<'de> for CreateLimitRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CreateLimitRequest
impl RefUnwindSafe for CreateLimitRequest
impl Send for CreateLimitRequest
impl Sync for CreateLimitRequest
impl Unpin for CreateLimitRequest
impl UnwindSafe for CreateLimitRequest
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§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