pub struct ErrorStream<E>(/* private fields */);Expand description
A non-empty stream of errors.
Logically, this type is unordered, and it is not guaranteed that the errors will be returned in the order they were added. Attach identifying information to your errors if you want to sort them.
This struct is intended to be used with:
- The CombineErrors trait, which allows you to combine a tuples of results.
- The CollectAllErrors trait, which allows you to collect errors from an iterator of results.
To create an ErrorStream from a single error, you can use from or into:
use spacetimedb_data_structures::error_stream::ErrorStream;
enum MyError {
A(u32),
B
}
let error: ErrorStream<MyError> = MyError::A(1).into();
// or
let error = ErrorStream::from(MyError::A(1));This does not allocate (unless your error allocates, of course).
Implementations§
Source§impl<E> ErrorStream<E>
impl<E> ErrorStream<E>
Sourcepub fn expect_nonempty<I: IntoIterator<Item = E>>(errors: I) -> Self
pub fn expect_nonempty<I: IntoIterator<Item = E>>(errors: I) -> Self
Build an error stream from a non-empty collection. If the collection is empty, panic.
Sourcepub fn add_extra_errors<T>(
result: Result<T, ErrorStream<E>>,
extra_errors: impl IntoIterator<Item = E>,
) -> Result<T, ErrorStream<E>>
pub fn add_extra_errors<T>( result: Result<T, ErrorStream<E>>, extra_errors: impl IntoIterator<Item = E>, ) -> Result<T, ErrorStream<E>>
Add some extra errors to a result.
If there are no errors, the result is not modified.
If there are errors, and the result is Err, the errors are added to the stream.
If there are errors, and the result is Ok, the Ok value is discarded, and the errors are returned in a stream.
Sourcepub fn iter(&self) -> impl Iterator<Item = &E>
pub fn iter(&self) -> impl Iterator<Item = &E>
Returns an iterator over the errors in the stream.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut E>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut E>
Returns a mutable iterator over the errors in the stream.
Sourcepub fn drain(&mut self) -> impl Iterator<Item = E> + '_
pub fn drain(&mut self) -> impl Iterator<Item = E> + '_
Returns an iterator over the errors in the stream, consuming the stream.
Sourcepub fn extend(&mut self, other: impl IntoIterator<Item = E>)
pub fn extend(&mut self, other: impl IntoIterator<Item = E>)
Extend the stream with another stream.
Source§impl<E: Ord + Eq> ErrorStream<E>
impl<E: Ord + Eq> ErrorStream<E>
Sourcepub fn sort_deduplicate(self) -> Self
pub fn sort_deduplicate(self) -> Self
Sort and deduplicate the errors in the error stream.
Source§impl<E: Eq + Hash> ErrorStream<E>
impl<E: Eq + Hash> ErrorStream<E>
Sourcepub fn hash_deduplicate(self) -> Self
pub fn hash_deduplicate(self) -> Self
Hash and deduplicate the errors in the error stream. The resulting error stream has an arbitrary order.
Trait Implementations§
Source§impl<E: Clone> Clone for ErrorStream<E>
impl<E: Clone> Clone for ErrorStream<E>
Source§fn clone(&self) -> ErrorStream<E>
fn clone(&self) -> ErrorStream<E>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<E: Debug> Debug for ErrorStream<E>
impl<E: Debug> Debug for ErrorStream<E>
Source§impl<E: Default> Default for ErrorStream<E>
impl<E: Default> Default for ErrorStream<E>
Source§fn default() -> ErrorStream<E>
fn default() -> ErrorStream<E>
Source§impl<E: Display> Display for ErrorStream<E>
impl<E: Display> Display for ErrorStream<E>
Source§impl<E> Error for ErrorStream<E>
impl<E> Error for ErrorStream<E>
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<E> From<E> for ErrorStream<E>
impl<E> From<E> for ErrorStream<E>
Source§impl<E> IntoIterator for ErrorStream<E>
impl<E> IntoIterator for ErrorStream<E>
Source§impl<E: PartialEq> PartialEq for ErrorStream<E>
impl<E: PartialEq> PartialEq for ErrorStream<E>
impl<E: Eq> Eq for ErrorStream<E>
impl<E> StructuralPartialEq for ErrorStream<E>
Auto Trait Implementations§
impl<E> Freeze for ErrorStream<E>where
E: Freeze,
impl<E> RefUnwindSafe for ErrorStream<E>where
E: RefUnwindSafe,
impl<E> Send for ErrorStream<E>where
E: Send,
impl<E> Sync for ErrorStream<E>where
E: Sync,
impl<E> Unpin for ErrorStream<E>where
E: Unpin,
impl<E> UnwindSafe for ErrorStream<E>where
E: RefUnwindSafe + UnwindSafe,
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more