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
impl Problems
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Constructor.
Sourcepub fn handle_type_as_critical<ErrorT>(&mut self)
pub fn handle_type_as_critical<ErrorT>(&mut self)
Marks a top error type as critical.
Sourcepub fn is_critical(&self, problem: &Problem) -> bool
pub fn is_critical(&self, problem: &Problem) -> bool
True if the problem’s top error is critical.
Sourcepub fn is_error_critical(&self, error: &CapturedError) -> bool
pub fn is_error_critical(&self, error: &CapturedError) -> bool
True if the error is critical.
Sourcepub fn check(self) -> Result<Self, Self>
pub fn check(self) -> Result<Self, Self>
Fails with self if there is at least one problem.
Other returns self.
Sourcepub fn into_unique(self) -> Self
pub fn into_unique(self) -> Self
Into unique problems.
Equality is tested for using the first CauseEquality or CauseComparison found in each problem.
Sourcepub fn iter_unique(self) -> impl Iterator<Item = Problem>
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.
Sourcepub fn iter_unique_refs<'this>(
&'this self,
) -> impl Iterator<Item = &'this Problem>
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 Error for Problems
impl Error for Problems
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl<ErrorT> FromIterator<ErrorT> for Problems
impl<ErrorT> FromIterator<ErrorT> for Problems
Source§fn from_iter<IntoIteratorT>(iterator: IntoIteratorT) -> Selfwhere
IntoIteratorT: IntoIterator<Item = ErrorT>,
fn from_iter<IntoIteratorT>(iterator: IntoIteratorT) -> Selfwhere
IntoIteratorT: IntoIterator<Item = ErrorT>,
Source§impl FromIterator<Problem> for Problems
impl FromIterator<Problem> for Problems
Source§impl<'this> IntoIterator for &'this Problems
impl<'this> IntoIterator for &'this Problems
Source§impl IntoIterator for Problems
Available on crate feature thin-vec only.
impl IntoIterator for Problems
thin-vec only.Auto Trait Implementations§
impl Freeze for Problems
impl !RefUnwindSafe for Problems
impl Send for Problems
impl Sync for Problems
impl Unpin for Problems
impl UnsafeUnpin for Problems
impl !UnwindSafe for Problems
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
Source§impl<ToStringT> IntoCommonProblem for ToStringTwhere
ToStringT: ToString,
impl<ToStringT> IntoCommonProblem for ToStringTwhere
ToStringT: ToString,
Source§fn gloss(self) -> Problem
fn gloss(self) -> Problem
Source§fn into_thread_problem(self) -> Problem
fn into_thread_problem(self) -> Problem
Source§impl<ErrorT> IntoProblem for ErrorT
impl<ErrorT> IntoProblem for ErrorT
Source§fn into_problem(self) -> Problem
fn into_problem(self) -> Problem
Source§impl<ErrorT> IntoSerdeProblem for ErrorT
impl<ErrorT> IntoSerdeProblem for ErrorT
Source§fn into_serde_serialize_problem(self) -> SerdeProblem
fn into_serde_serialize_problem(self) -> SerdeProblem
serde only.Source§fn into_serde_deserialize_problem(self) -> SerdeProblem
fn into_serde_deserialize_problem(self) -> SerdeProblem
serde only.