Skip to main content

ItemError

Struct ItemError 

Source
#[non_exhaustive]
pub struct ItemError { pub code: String, pub class: ErrorClass, pub message: String, pub retry_after_ms: Option<u64>, pub detail: Option<ItemErrorDetail>, }
Expand description

An item’s error in a batch reply: {code, class, message, retry_after_ms?, detail?}.

Non-exhaustive so later optional members are additive: use ItemError::new or ItemError::for_code and the with_* setters, or decode one.

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: String

A per-item code this crate lists; any other value decodes as a plain string.

§class: ErrorClass§message: String§retry_after_ms: Option<u64>

When the provider said how long to wait.

§detail: Option<ItemErrorDetail>

Present only on codes that define one (ANSWER_TOO_LARGE).

Implementations§

Source§

impl ItemError

Source

pub fn new( code: impl Into<String>, class: ErrorClass, message: impl Into<String>, ) -> Self

Source

pub fn for_code(code: &str, message: impl Into<String>) -> Self

An error with the class the vocabulary gives code; a code this crate does not list gets ErrorClass::Permanent.

Source

pub fn answer_too_large(field: impl Into<String>, limit: u64, size: u64) -> Self

answer_too_large for the answer to field, size bytes against a bound of limit.

Source

pub fn with_retry_after_ms(self, retry_after_ms: u64) -> Self

Source

pub fn with_detail(self, detail: ItemErrorDetail) -> Self

Source

pub fn is_retried_on_resend(&self) -> bool

Whether a re-send of the batch asks the provider again for an item whose stored outcome is this error. A stored transient error is retried and its new outcome replaces it; a stored permanent one (and one of an unknown class) is returned as stored, with no provider call.

Source

pub fn is_stored(&self) -> bool

Whether a runner records this error as the item’s outcome. Every error is, except the ones that say nothing about the item: auth_failed, model_unavailable, account_limit_exhausted and account_not_entitled. The item stays unanswered, and a re-send (after a re-login, a catalog fix, the allocation’s reset or an operator’s fix) asks the provider again.

This answers for an item the provider actually answered with this error. A rate_limited item is stored like any transient error; the items after it that a rate limit stopped the call from sending carry rate_limited in the reply but are never recorded, which is the runner’s rule for unsent items and not something this code decides.

Source

pub fn stops_the_call(&self) -> bool

Whether this error, once an item ends with it, stops the call: no further item is sent to the provider in that call, and every item the call leaves unanswered carries the same code. True for the batch-level codes and rate_limited.

Trait Implementations§

Source§

impl Clone for ItemError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ItemError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ItemError

Source§

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 PartialEq for ItemError

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ItemError

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ItemError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.