pub struct CloneableError(/* private fields */);Expand description
An Error that can be cloned, for sharing one fallible source across
several consumers (for example a shared future two streams both await).
The error is held behind an Arc, so a clone shares it rather than
rebuilding it. Every accessor — is_not_found, fence_reason,
is_backpressure, is_commit_status_unknown, external_source — therefore
answers the same on every clone, including external_source, whose downcast
a message-based rebuild could not preserve. Use CloneableError::inner to
borrow the error and CloneableError::into_inner to recover it by value.
Implementations§
Source§impl CloneableError
impl CloneableError
Sourcepub fn new(error: Error) -> Self
pub fn new(error: Error) -> Self
Wrap an Error so it can be shared and cloned.
An already-shared error reuses its inner Arc rather than nesting
another Error::Shared, so repeatedly wrapping and recovering the
same error keeps the wrapper flat instead of growing a Shared chain.
Sourcepub fn into_inner(self) -> Error
pub fn into_inner(self) -> Error
Recover the error by value. When other clones are still alive the error
cannot be moved out, so it is returned wrapped in Error::Shared,
which answers every accessor the same as the error it wraps.