Skip to main content

Problems

Struct Problems 

Source
pub struct Problems {
    pub problems: ThinVec<Problem>,
    pub critical_error_types: HashSet<TypeId>,
}
Expand description

A simple wrapper for a vector of Problem.

Useful for accumulating problems, as it implements ProblemReceiver. By default it will swallow all problems into its vector. However, it can also be configured to fail fast on specific error types by calling handle_type_as_critical before use.

After use, you may want to call check to fail if there were problems.

Note that this type implements Error and as such can be used in the causation chain of a Problem. This can be thought of as “packing” many problems into one. It can then be “unpacked” via Problem::into_problems.

Fields§

§problems: ThinVec<Problem>

Problems.

§critical_error_types: HashSet<TypeId>

Critical error type IDs.

Implementations§

Source§

impl Problems

Source

pub fn with_capacity(capacity: usize) -> Self

Constructor.

Source

pub fn is_empty(&self) -> bool

True if there are no problems.

Source

pub fn count(&self) -> usize

The number of problems.

Source

pub fn iter(&self) -> Iter<'_, Problem>

Iterate problems.

Source

pub fn handle_type_as_critical<ErrorT>(&mut self)
where ErrorT: Any + Error,

Marks a top error type as critical.

Source

pub fn is_critical(&self, problem: &Problem) -> bool

True if the problem’s top error is critical.

Source

pub fn is_error_critical(&self, error: &CapturedError) -> bool

True if the error is critical.

Source

pub fn add<ProblemT>(&mut self, problem: ProblemT)
where ProblemT: Into<Problem>,

Add a problem.

Source

pub fn check(self) -> Result<Self, Self>

Fails with self if there is at least one problem.

Other returns self.

Source

pub fn into_unique(self) -> Self

Into unique problems.

Equality is tested for using the first CauseEquality or CauseComparison found in each problem.

Source

pub fn iter_unique(self) -> impl Iterator<Item = Problem>

Iterate unique problems.

Equality is tested for using the first CauseEquality or CauseComparison found in each problem.

Source

pub fn iter_unique_refs<'this>( &'this self, ) -> impl Iterator<Item = &'this Problem>

Iterate unique problems.

Equality is tested for using the first CauseEquality or CauseComparison found in each problem.

Trait Implementations§

Source§

impl Debug for Problems

Source§

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

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

impl Default for Problems

Source§

fn default() -> Problems

Returns the “default value” for a type. Read more
Source§

impl Display for Problems

Source§

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

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

impl Error for Problems

1.30.0 · Source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Problem> for Problems

Source§

fn from(problem: Problem) -> Self

Converts to this type from the input type.
Source§

impl From<ThinVec<Problem>> for Problems

Source§

fn from(problems: ThinVec<Problem>) -> Self

Converts to this type from the input type.
Source§

impl<ErrorT> FromIterator<ErrorT> for Problems
where ErrorT: 'static + Error + Send + Sync,

Source§

fn from_iter<IntoIteratorT>(iterator: IntoIteratorT) -> Self
where IntoIteratorT: IntoIterator<Item = ErrorT>,

Creates a value from an iterator. Read more
Source§

impl FromIterator<Problem> for Problems

Source§

fn from_iter<IntoIteratorT>(iterator: IntoIteratorT) -> Self
where IntoIteratorT: IntoIterator<Item = Problem>,

Creates a value from an iterator. Read more
Source§

impl<'this> IntoIterator for &'this Problems

Source§

type Item = &'this Problem

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'this, Problem>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for Problems

Available on crate feature thin-vec only.
Source§

type Item = Problem

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Problem>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl ProblemReceiver for Problems

Source§

fn give(&mut self, problem: Problem) -> Result<(), Problem>

Gives a problem to the receiver. Read more

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> 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<ToStringT> IntoCommonProblem for ToStringT
where ToStringT: ToString,

Source§

fn gloss(self) -> Problem

Into a GlossError problem.
Source§

fn into_thread_problem(self) -> Problem

Into a ThreadError problem.
Source§

impl<ErrorT> IntoProblem for ErrorT
where ErrorT: 'static + Error + Send + Sync,

Source§

impl<ErrorT> IntoSerdeProblem for ErrorT
where ErrorT: 'static + Error + Send + Sync,

Source§

fn into_serde_serialize_problem(self) -> SerdeProblem

Available on crate feature serde only.
Source§

fn into_serde_deserialize_problem(self) -> SerdeProblem

Available on crate feature serde only.
Source§

impl<ErrorT> IterateErrorSources for ErrorT
where ErrorT: 'static + Error,

Source§

fn iter_sources<'this>(&'this self) -> ErrorSourceIterator<'this>

Iterate the Error::source chain.
Source§

impl<'this, ProblemReceiverT> ProblemReceiverAsRef<'this, ProblemReceiverT> for ProblemReceiverT
where ProblemReceiverT: ProblemReceiver,

Source§

fn as_ref(&'this mut self) -> Arc<RefCell<&'this mut dyn ProblemReceiver>>

As problem receiver reference.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.