#[non_exhaustive]pub struct Refusal {
pub code: String,
pub message: String,
pub detail: Box<RefusalDetail>,
}Expand description
An admission refusal: the body of the ERROR frame a batch call answers
with, {code, message, detail}, the shape of subc_protocol::ErrorBody
with a typed detail.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.code: StringAn admission code this crate lists; any other value decodes as a plain string.
message: String§detail: Box<RefusalDetail>Boxed so a Result<_, Refusal> stays small.
Implementations§
Source§impl Refusal
impl Refusal
Sourcepub fn new(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn new(code: impl Into<String>, message: impl Into<String>) -> Self
A refusal with code, carrying the class the vocabulary gives it; a
code this crate does not list gets ErrorClass::Permanent.
pub fn with_detail(self, detail: RefusalDetail) -> Self
Sourcepub fn invalid_params(
field: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn invalid_params( field: impl Into<String>, message: impl Into<String>, ) -> Self
invalid_params naming field.
Sourcepub fn over_limit(
field: impl Into<String>,
limit: u64,
message: impl Into<String>,
) -> Self
pub fn over_limit( field: impl Into<String>, limit: u64, message: impl Into<String>, ) -> Self
invalid_params naming field and the limit it exceeded.
Sourcepub fn batch_id_reuse(field: impl Into<String>) -> Self
pub fn batch_id_reuse(field: impl Into<String>) -> Self
batch_id_reuse naming the first differing field.
pub fn model_unknown(model: impl Into<String>) -> Self
Sourcepub fn model_not_classifier(
model: impl Into<String>,
kind: impl Into<String>,
) -> Self
pub fn model_not_classifier( model: impl Into<String>, kind: impl Into<String>, ) -> Self
classifier/v1’s model_not_classifier.
Sourcepub fn model_not_extractor(model: impl Into<String>, kind: Option<&str>) -> Self
pub fn model_not_extractor(model: impl Into<String>, kind: Option<&str>) -> Self
extractor/v1’s model_not_extractor. kind is the row’s kind,
None when the row states none; the refusal never invents one.
pub fn cost_exceeded(estimate_usd: Number, max_cost_usd: Number) -> Self
pub fn account_walled() -> Self
Sourcepub fn auth_failed() -> Self
pub fn auth_failed() -> Self
The call’s first provider call met a 401 or 403.
The call’s first provider call met a 404 for model.
Sourcepub fn account_limit_exhausted() -> Self
pub fn account_limit_exhausted() -> Self
The call’s first provider call met Workers AI code 3036.
Sourcepub fn account_not_entitled() -> Self
pub fn account_not_entitled() -> Self
The call’s first provider call met Workers AI code 5035, 5016 or 3023.
pub fn batch_in_progress(retry_after_ms: u64) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Refusal
impl<'de> Deserialize<'de> for Refusal
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>,
Source§impl Error for Refusal
impl Error for Refusal
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()