#[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 classify.run
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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.code: StringOne of ADMISSION_CODES; 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 contract 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
pub fn model_not_classifier( model: impl Into<String>, kind: impl Into<String>, ) -> Self
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.
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>,
Deserialize this value from the given Serde deserializer. Read more
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)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
impl StructuralPartialEq for Refusal
Auto Trait Implementations§
impl Freeze for Refusal
impl RefUnwindSafe for Refusal
impl Send for Refusal
impl Sync for Refusal
impl Unpin for Refusal
impl UnsafeUnpin for Refusal
impl UnwindSafe for Refusal
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