Skip to main content

Causes

Trait Causes 

Source
pub trait Causes {
Show 15 methods // Required methods fn problem(&self) -> &Problem; fn iter_causes(&self) -> impl Iterator<Item = &Cause>; // Provided methods fn iter_causes_with_error_type<ErrorT>( &self, ) -> impl Iterator<Item = CauseRef<'_, ErrorT>> where ErrorT: 'static + Error { ... } fn iter_causes_until_error_type<ErrorT>( &self, ) -> impl Iterator<Item = &Cause> where ErrorT: 'static + Error { ... } fn iter_causes_from_error_type<ErrorT>( &self, ) -> impl Iterator<Item = &Cause> where ErrorT: 'static + Error { ... } fn iter_causes_with_error<ErrorT>( &self, error: &ErrorT, ) -> impl Iterator<Item = CauseRef<'_, ErrorT>> where ErrorT: 'static + Error + PartialEq { ... } fn iter_causes_with_attachment_type<AttachmentT>( &self, ) -> impl Iterator<Item = (&Cause, &AttachmentT)> where AttachmentT: 'static { ... } fn cause_with_error_type<ErrorT>(&self) -> Option<CauseRef<'_, ErrorT>> where ErrorT: 'static + Error { ... } fn cause_with_error<ErrorT>( &self, error: &ErrorT, ) -> Option<CauseRef<'_, ErrorT>> where ErrorT: 'static + Error + PartialEq { ... } fn cause_with_attachment_type<AttachmentT>( &self, ) -> Option<(&Cause, &AttachmentT)> where AttachmentT: 'static { ... } fn iter_errors(&self) -> impl Iterator<Item = &CapturedError> { ... } fn iter_errors_of_type<ErrorT>(&self) -> impl Iterator<Item = &ErrorT> where ErrorT: 'static + Error { ... } fn error_of_type<ErrorT>(&self) -> Option<&ErrorT> where ErrorT: 'static + Error { ... } fn has_error_type<ErrorT>(&self) -> bool where ErrorT: 'static + Error { ... } fn has_error<ErrorT>(&self, error: &ErrorT) -> bool where ErrorT: 'static + Error + PartialEq { ... }
}
Expand description

Access to causes.

Required Methods§

Source

fn problem(&self) -> &Problem

The problem that owns this causation chain.

Source

fn iter_causes(&self) -> impl Iterator<Item = &Cause>

Iterate causes in order of causation.

You can call iter_sources on each to further iterate the “branches” of the tree:

for cause in problem.iter_causes() {
    for error in error.iter_sources() {
        println!("{}", error);
    }
}

Provided Methods§

Source

fn iter_causes_with_error_type<ErrorT>( &self, ) -> impl Iterator<Item = CauseRef<'_, ErrorT>>
where ErrorT: 'static + Error,

Iterate causes with an error of a type.

Will recurse into source.

Source

fn iter_causes_until_error_type<ErrorT>(&self) -> impl Iterator<Item = &Cause>
where ErrorT: 'static + Error,

Iterate causes in order of causation until (but not including) a cause with an error of a type.

Will recurse into source.

Source

fn iter_causes_from_error_type<ErrorT>(&self) -> impl Iterator<Item = &Cause>
where ErrorT: 'static + Error,

Iterate causes in order of causation from a cause with an error of a type.

Will recurse into source.

Source

fn iter_causes_with_error<ErrorT>( &self, error: &ErrorT, ) -> impl Iterator<Item = CauseRef<'_, ErrorT>>
where ErrorT: 'static + Error + PartialEq,

Iterate causes with the error.

Will recurse into source.

Source

fn iter_causes_with_attachment_type<AttachmentT>( &self, ) -> impl Iterator<Item = (&Cause, &AttachmentT)>
where AttachmentT: 'static,

Iterate causes with an attachment of a type.

Source

fn cause_with_error_type<ErrorT>(&self) -> Option<CauseRef<'_, ErrorT>>
where ErrorT: 'static + Error,

The first cause with an error of a type.

Will recurse into source.

Source

fn cause_with_error<ErrorT>( &self, error: &ErrorT, ) -> Option<CauseRef<'_, ErrorT>>
where ErrorT: 'static + Error + PartialEq,

The first cause with the error.

Will recurse into source.

Source

fn cause_with_attachment_type<AttachmentT>( &self, ) -> Option<(&Cause, &AttachmentT)>
where AttachmentT: 'static,

The first cause with an attachment of a type.

Source

fn iter_errors(&self) -> impl Iterator<Item = &CapturedError>

Iterate errors in order of causation.

Note that this will not include source, however you can call iter_sources on each to further iterate the “branches” of the tree:

for error in problem.iter_errors() {
    for error in error.as_ref().iter_sources() {
        println!("{}", error);
    }
}
Source

fn iter_errors_of_type<ErrorT>(&self) -> impl Iterator<Item = &ErrorT>
where ErrorT: 'static + Error,

Iterate errors of a type in order of causation.

Note that this will not include source.

Source

fn error_of_type<ErrorT>(&self) -> Option<&ErrorT>
where ErrorT: 'static + Error,

The first error of a type.

Note that this will not include source.

Source

fn has_error_type<ErrorT>(&self) -> bool
where ErrorT: 'static + Error,

Whether we have an error of a type in the causation chain.

Will recurse into source.

Source

fn has_error<ErrorT>(&self, error: &ErrorT) -> bool
where ErrorT: 'static + Error + PartialEq,

Whether we have the error in the causation chain.

Will recurse into source.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§