#[non_exhaustive]pub enum StreamErrorKind {
Connectivity,
ConnectionLost,
RateLimited(Option<Duration>),
ServerError,
InvalidRequest,
Unknown,
}Expand description
Classification of a StreamDelta::Error event.
Mirrors ChatOutcome’s error
variants so providers that emit errors via streaming preserve the
same precision that non-streaming chat() callers see — every
supported provider can map its underlying error (HTTP status,
validation failure, mid-stream disconnect) directly onto one of
these categories at the construction site.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Connectivity
The request could not establish a provider connection because DNS, routing, or the network is unavailable. Callers may wait indefinitely for connectivity, provided cancellation remains cooperative.
ConnectionLost
An established provider response stream lost its underlying network
connection. It has the same wait policy as Self::Connectivity, but
durable runtimes must close that provider call’s audit attempt before
retrying it.
RateLimited(Option<Duration>)
Provider returned HTTP 429 / explicit rate-limit signal.
Carries the server-supplied retry delay when the provider gave one —
a Retry-After header, or a hint embedded in the error body (Gemini’s
google.rpc.RetryInfo, OpenAI’s “try again in 20s”). None when the
provider supplied no usable hint, in which case callers use backoff.
ServerError
Provider returned HTTP 5xx or reported a transient runtime failure.
InvalidRequest
Caller-side error: validation failure before dispatch, HTTP 4xx other than 429, or a non-retriable provider rejection.
Unknown
Escape hatch for a streaming error a provider could not classify into one of the categories above.
Producers should prefer a specific variant whenever the
underlying signal (HTTP status, validation failure, mid-stream
disconnect) allows it; Unknown exists so future error sources
and providers can be added without a breaking change. It is
treated as non-recoverable by StreamErrorKind::is_recoverable
(callers should not blindly retry an unclassified failure).
Implementations§
Source§impl StreamErrorKind
impl StreamErrorKind
Sourcepub const fn is_recoverable(self) -> bool
pub const fn is_recoverable(self) -> bool
true when the error is potentially transient and the caller
may retry. Connectivity, rate-limit, and server errors are
recoverable; invalid-request is not.
Sourcepub const fn retry_after(self) -> Option<Duration>
pub const fn retry_after(self) -> Option<Duration>
The server-supplied retry delay carried by a rate-limit error, if any.
Sourcepub const fn is_connectivity(self) -> bool
pub const fn is_connectivity(self) -> bool
true for failures governed by the unbounded, cancellable offline wait.
Trait Implementations§
Source§impl Clone for StreamErrorKind
impl Clone for StreamErrorKind
Source§fn clone(&self) -> StreamErrorKind
fn clone(&self) -> StreamErrorKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for StreamErrorKind
Source§impl Debug for StreamErrorKind
impl Debug for StreamErrorKind
impl Eq for StreamErrorKind
Source§impl PartialEq for StreamErrorKind
impl PartialEq for StreamErrorKind
impl StructuralPartialEq for StreamErrorKind
Auto Trait Implementations§
impl Freeze for StreamErrorKind
impl RefUnwindSafe for StreamErrorKind
impl Send for StreamErrorKind
impl Sync for StreamErrorKind
impl Unpin for StreamErrorKind
impl UnsafeUnpin for StreamErrorKind
impl UnwindSafe for StreamErrorKind
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.