Struct Failure
pub struct Failure(/* private fields */);Expand description
A failure, as recorded and as returned to callers. One pointer wide (the
fields are boxed), so a Result that may carry one stays small; it
reads as its FailureData.
Implementations§
§impl Failure
impl Failure
pub fn fatal(message: impl Into<String>) -> Self
pub fn fatal(message: impl Into<String>) -> Self
A failure that is never retried (FatalError in TypeScript,
fusee.Fatal in Python).
pub fn code(self, code: impl Into<String>) -> Self
pub fn details(self, details: Value) -> Self
pub fn retryable(self, retryable: bool) -> Self
pub fn retryable(self, retryable: bool) -> Self
false makes the failure final: no retry policy retries it.
pub fn stack(self, stack: impl Into<String>) -> Self
pub fn stack(self, stack: impl Into<String>) -> Self
Records a stack trace, cut to STACK_LIMIT bytes.
pub fn caused_by(self, cause: impl Into<Failure>) -> Self
pub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether a retry policy may retry this failure (it was not marked final).
pub fn has_kind(&self, kind: &str) -> bool
pub fn has_kind(&self, kind: &str) -> bool
Whether this failure, or one of its causes, has type kind.
pub fn to_payload(&self) -> Payload
pub fn to_payload(&self) -> Payload
The failure as it is recorded.
pub fn from_payload(p: &[u8]) -> Self
pub fn from_payload(p: &[u8]) -> Self
Reads a recorded failure: an envelope, or plain text as its message.
pub fn from_error(e: &(dyn Error + 'static), kind: Option<String>) -> Self
pub fn from_error(e: &(dyn Error + 'static), kind: Option<String>) -> Self
A failure from an error and its source chain. kind names the
outermost error’s type.
Trait Implementations§
§impl Deref for Failure
impl Deref for Failure
§type Target = FailureData
type Target = FailureData
The resulting type after dereferencing.
§fn deref(&self) -> &FailureData
fn deref(&self) -> &FailureData
Dereferences the value.
§impl DerefMut for Failure
impl DerefMut for Failure
§fn deref_mut(&mut self) -> &mut FailureData
fn deref_mut(&mut self) -> &mut FailureData
Mutably dereferences the value.
§impl<'de> Deserialize<'de> for Failure
impl<'de> Deserialize<'de> for Failure
§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
impl Eq for Failure
§impl Error for Failure
impl Error for Failure
§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 From<FailureData> for Failure
impl From<FailureData> for Failure
§fn from(d: FailureData) -> Self
fn from(d: FailureData) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for Failure
Auto Trait Implementations§
impl Forget for Failure
impl Freeze for Failure
impl Move for Failure
impl RefUnwindSafe for Failure
impl Send for Failure
impl Sync for Failure
impl Unpin for Failure
impl UnsafeUnpin for Failure
impl UnwindSafe for Failure
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