Trait eccodes::FallibleIterator [−][src]
pub trait FallibleIterator {
type Item;
type Error;
Show 53 methods
fn next(&mut self) -> Result<Option<Self::Item>, Self::Error>;
fn size_hint(&self) -> (usize, Option<usize>) { ... }
fn count(self) -> Result<usize, Self::Error> { ... }
fn last(self) -> Result<Option<Self::Item>, Self::Error> { ... }
fn nth(&mut self, n: usize) -> Result<Option<Self::Item>, Self::Error> { ... }
fn step_by(self, step: usize) -> StepBy<Self> { ... }
fn chain<I>(self, it: I) -> Chain<Self, I>
where
I: IntoFallibleIterator<Item = Self::Item, Error = Self::Error>,
{ ... }
fn zip<I>(
self,
o: I
) -> Zip<Self, <I as IntoFallibleIterator>::IntoFallibleIter>
where
I: IntoFallibleIterator<Error = Self::Error>,
{ ... }
fn map<F, B>(self, f: F) -> Map<Self, F>
where
F: FnMut(Self::Item) -> Result<B, Self::Error>,
{ ... }
fn for_each<F>(self, f: F) -> Result<(), Self::Error>
where
F: FnMut(Self::Item) -> Result<(), Self::Error>,
{ ... }
fn filter<F>(self, f: F) -> Filter<Self, F>
where
F: FnMut(&Self::Item) -> Result<bool, Self::Error>,
{ ... }
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
where
F: FnMut(Self::Item) -> Result<Option<B>, Self::Error>,
{ ... }
fn enumerate(self) -> Enumerate<Self> { ... }
fn peekable(self) -> Peekable<Self> { ... }
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
where
P: FnMut(&Self::Item) -> Result<bool, Self::Error>,
{ ... }
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
where
P: FnMut(&Self::Item) -> Result<bool, Self::Error>,
{ ... }
fn skip(self, n: usize) -> Skip<Self> { ... }
fn take(self, n: usize) -> Take<Self> { ... }
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
where
F: FnMut(&mut St, Self::Item) -> Result<Option<B>, Self::Error>,
{ ... }
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
where
F: FnMut(Self::Item) -> Result<U, Self::Error>,
U: IntoFallibleIterator<Error = Self::Error>,
{ ... }
fn flatten(self) -> Flatten<Self>
where
Self::Item: IntoFallibleIterator,
<Self::Item as IntoFallibleIterator>::Error == Self::Error,
{ ... }
fn fuse(self) -> Fuse<Self> { ... }
fn inspect<F>(self, f: F) -> Inspect<Self, F>
where
F: FnMut(&Self::Item) -> Result<(), Self::Error>,
{ ... }
fn by_ref(&mut self) -> &mut Self { ... }
fn collect<T>(self) -> Result<T, Self::Error>
where
T: FromFallibleIterator<Self::Item>,
{ ... }
fn partition<B, F>(self, f: F) -> Result<(B, B), Self::Error>
where
F: FnMut(&Self::Item) -> Result<bool, Self::Error>,
B: Default + Extend<Self::Item>,
{ ... }
fn fold<B, F>(self, init: B, f: F) -> Result<B, Self::Error>
where
F: FnMut(B, Self::Item) -> Result<B, Self::Error>,
{ ... }
fn try_fold<B, E, F>(&mut self, init: B, f: F) -> Result<B, E>
where
E: From<Self::Error>,
F: FnMut(B, Self::Item) -> Result<B, E>,
{ ... }
fn all<F>(&mut self, f: F) -> Result<bool, Self::Error>
where
F: FnMut(Self::Item) -> Result<bool, Self::Error>,
{ ... }
fn any<F>(&mut self, f: F) -> Result<bool, Self::Error>
where
F: FnMut(Self::Item) -> Result<bool, Self::Error>,
{ ... }
fn find<F>(&mut self, f: F) -> Result<Option<Self::Item>, Self::Error>
where
F: FnMut(&Self::Item) -> Result<bool, Self::Error>,
{ ... }
fn find_map<B, F>(&mut self, f: F) -> Result<Option<B>, Self::Error>
where
F: FnMut(Self::Item) -> Result<Option<B>, Self::Error>,
{ ... }
fn position<F>(&mut self, f: F) -> Result<Option<usize>, Self::Error>
where
F: FnMut(Self::Item) -> Result<bool, Self::Error>,
{ ... }
fn max(self) -> Result<Option<Self::Item>, Self::Error>
where
Self::Item: Ord,
{ ... }
fn max_by_key<B, F>(self, f: F) -> Result<Option<Self::Item>, Self::Error>
where
F: FnMut(&Self::Item) -> Result<B, Self::Error>,
B: Ord,
{ ... }
fn max_by<F>(self, f: F) -> Result<Option<Self::Item>, Self::Error>
where
F: FnMut(&Self::Item, &Self::Item) -> Result<Ordering, Self::Error>,
{ ... }
fn min(self) -> Result<Option<Self::Item>, Self::Error>
where
Self::Item: Ord,
{ ... }
fn min_by_key<B, F>(self, f: F) -> Result<Option<Self::Item>, Self::Error>
where
F: FnMut(&Self::Item) -> Result<B, Self::Error>,
B: Ord,
{ ... }
fn min_by<F>(self, f: F) -> Result<Option<Self::Item>, Self::Error>
where
F: FnMut(&Self::Item, &Self::Item) -> Result<Ordering, Self::Error>,
{ ... }
fn rev(self) -> Rev<Self>
where
Self: DoubleEndedFallibleIterator,
{ ... }
fn unzip<A, B, FromA, FromB>(self) -> Result<(FromA, FromB), Self::Error>
where
Self: FallibleIterator<Item = (A, B)>,
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
{ ... }
fn cloned<'a, T>(self) -> Cloned<Self>
where
Self: FallibleIterator<Item = &'a T>,
T: 'a + Clone,
{ ... }
fn cycle(self) -> Cycle<Self>
where
Self: Clone,
{ ... }
fn cmp<I>(self, other: I) -> Result<Ordering, Self::Error>
where
I: IntoFallibleIterator<Item = Self::Item, Error = Self::Error>,
Self::Item: Ord,
{ ... }
fn partial_cmp<I>(self, other: I) -> Result<Option<Ordering>, Self::Error>
where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
{ ... }
fn eq<I>(self, other: I) -> Result<bool, Self::Error>
where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialEq<<I as IntoFallibleIterator>::Item>,
{ ... }
fn ne<I>(self, other: I) -> Result<bool, Self::Error>
where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialEq<<I as IntoFallibleIterator>::Item>,
{ ... }
fn lt<I>(self, other: I) -> Result<bool, Self::Error>
where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
{ ... }
fn le<I>(self, other: I) -> Result<bool, Self::Error>
where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
{ ... }
fn gt<I>(self, other: I) -> Result<bool, Self::Error>
where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
{ ... }
fn ge<I>(self, other: I) -> Result<bool, Self::Error>
where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
{ ... }
fn iterator(self) -> Iterator<Self> { ... }
fn map_err<B, F>(self, f: F) -> MapErr<Self, F>
where
F: FnMut(Self::Error) -> B,
{ ... }
}
Expand description
An Iterator
-like trait that allows for calculation of items to fail.
Associated Types
Required methods
Provided methods
Returns bounds on the remaining length of the iterator.
Specifically, the first half of the returned tuple is a lower bound and the second half is an upper bound.
For the upper bound, None
indicates that the upper bound is either
unknown or larger than can be represented as a usize
.
Both bounds assume that all remaining calls to next
succeed. That is,
next
could return an Err
in fewer calls than specified by the lower
bound.
The default implementation returns (0, None)
, which is correct for
any iterator.
Consumes the iterator, returning the number of remaining items.
Returns the last element of the iterator.
Returns the n
th element of the iterator.
Returns an iterator starting at the same point, but stepping by the given amount at each iteration.
Panics
Panics if step
is 0.
Returns an iterator which yields the elements of this iterator followed by another.
fn zip<I>(
self,
o: I
) -> Zip<Self, <I as IntoFallibleIterator>::IntoFallibleIter> where
I: IntoFallibleIterator<Error = Self::Error>,
fn zip<I>(
self,
o: I
) -> Zip<Self, <I as IntoFallibleIterator>::IntoFallibleIter> where
I: IntoFallibleIterator<Error = Self::Error>,
Returns an iterator that yields pairs of this iterator’s and another iterator’s values.
Returns an iterator which applies a fallible transform to the elements of the underlying iterator.
Calls a fallible closure on each element of an iterator.
Returns an iterator which uses a predicate to determine which values should be yielded. The predicate may fail; such failures are passed to the caller.
Returns an iterator which both filters and maps. The closure may fail; such failures are passed along to the consumer.
Returns an iterator which yields the current iteration count as well as the value.
Returns an iterator that can peek at the next element without consuming it.
Returns an iterator that skips elements based on a predicate.
Returns an iterator that yields elements based on a predicate.
Returns an iterator which skips the first n
values of this iterator.
Returns an iterator that yields only the first n
values of this
iterator.
Returns an iterator which applies a stateful map to values of this iterator.
Returns an iterator which maps this iterator’s elements to iterators, yielding those iterators’ values.
fn flatten(self) -> Flatten<Self> where
Self::Item: IntoFallibleIterator,
<Self::Item as IntoFallibleIterator>::Error == Self::Error,
fn flatten(self) -> Flatten<Self> where
Self::Item: IntoFallibleIterator,
<Self::Item as IntoFallibleIterator>::Error == Self::Error,
Returns an iterator which flattens an iterator of iterators, yielding those iterators’ values.
Returns an iterator which yields this iterator’s elements and ends after
the first Ok(None)
.
The behavior of calling next
after it has previously returned
Ok(None)
is normally unspecified. The iterator returned by this method
guarantees that Ok(None)
will always be returned.
Returns an iterator which passes each element to a closure before returning it.
Borrow an iterator rather than consuming it.
This is useful to allow the use of iterator adaptors that would otherwise consume the value.
Transforms the iterator into a collection.
An Err
will be returned if any invocation of next
returns Err
.
Transforms the iterator into two collections, partitioning elements by a closure.
Applies a function over the elements of the iterator, producing a single final value.
Applies a function over the elements of the iterator, producing a single final value.
This is used as the “base” of many methods on FallibleIterator
.
Determines if all elements of this iterator match a predicate.
Determines if any element of this iterator matches a predicate.
Returns the first element of the iterator that matches a predicate.
Applies a function to the elements of the iterator, returning the first non-None
result.
Returns the position of the first element of this iterator that matches a predicate. The predicate may fail; such failures are returned to the caller.
Returns the maximal element of the iterator.
Returns the element of the iterator which gives the maximum value from the function.
Returns the element that gives the maximum value with respect to the function.
Returns the minimal element of the iterator.
Returns the element of the iterator which gives the minimum value from the function.
Returns the element that gives the minimum value with respect to the function.
fn rev(self) -> Rev<Self> where
Self: DoubleEndedFallibleIterator,
fn rev(self) -> Rev<Self> where
Self: DoubleEndedFallibleIterator,
Returns an iterator that yields this iterator’s items in the opposite order.
Converts an iterator of pairs into a pair of containers.
Returns an iterator which clones all of its elements.
Returns an iterator which repeas this iterator endlessly.
Lexicographically compares the elements of this iterator to that of another.
fn partial_cmp<I>(self, other: I) -> Result<Option<Ordering>, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
fn partial_cmp<I>(self, other: I) -> Result<Option<Ordering>, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
Lexicographically compares the elements of this iterator to that of another.
Determines if the elements of this iterator are equal to those of another.
Determines if the elements of this iterator are not equal to those of another.
fn lt<I>(self, other: I) -> Result<bool, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
fn lt<I>(self, other: I) -> Result<bool, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
Determines if the elements of this iterator are lexicographically less than those of another.
fn le<I>(self, other: I) -> Result<bool, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
fn le<I>(self, other: I) -> Result<bool, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
Determines if the elements of this iterator are lexicographically less than or equal to those of another.
fn gt<I>(self, other: I) -> Result<bool, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
fn gt<I>(self, other: I) -> Result<bool, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
Determines if the elements of this iterator are lexicographically greater than those of another.
fn ge<I>(self, other: I) -> Result<bool, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
fn ge<I>(self, other: I) -> Result<bool, Self::Error> where
I: IntoFallibleIterator<Error = Self::Error>,
Self::Item: PartialOrd<<I as IntoFallibleIterator>::Item>,
Determines if the elements of this iterator are lexicographically greater than or equal to those of another.
Returns a normal (non-fallible) iterator over Result<Item, Error>
.
Implementations on Foreign Types
impl<T, U> FallibleIterator for Chain<T, U> where
T: FallibleIterator,
U: FallibleIterator<Item = <T as FallibleIterator>::Item, Error = <T as FallibleIterator>::Error>,
impl<T, U> FallibleIterator for Chain<T, U> where
T: FallibleIterator,
U: FallibleIterator<Item = <T as FallibleIterator>::Item, Error = <T as FallibleIterator>::Error>,
type Item = <T as FallibleIterator>::Item
type Error = <T as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<T as FallibleIterator>::Item>, <T as FallibleIterator>::Error>
pub fn try_fold<B, E, F>(&mut self, init: B, f: F) -> Result<B, E> where
E: From<<T as FallibleIterator>::Error>,
F: FnMut(B, <T as FallibleIterator>::Item) -> Result<B, E>,
pub fn find<F>(
&mut self,
f: F
) -> Result<Option<<T as FallibleIterator>::Item>, <T as FallibleIterator>::Error> where
F: FnMut(&<T as FallibleIterator>::Item) -> Result<bool, <T as FallibleIterator>::Error>,
pub fn last(
self
) -> Result<Option<<T as FallibleIterator>::Item>, <T as FallibleIterator>::Error>
impl<I, P> FallibleIterator for SkipWhile<I, P> where
I: FallibleIterator,
P: FnMut(&<I as FallibleIterator>::Item) -> Result<bool, <I as FallibleIterator>::Error>,
impl<I, P> FallibleIterator for SkipWhile<I, P> where
I: FallibleIterator,
P: FnMut(&<I as FallibleIterator>::Item) -> Result<bool, <I as FallibleIterator>::Error>,
impl<T, F, B> FallibleIterator for Map<T, F> where
T: FallibleIterator,
F: FnMut(<T as FallibleIterator>::Item) -> Result<B, <T as FallibleIterator>::Error>,
impl<T, F, B> FallibleIterator for Map<T, F> where
T: FallibleIterator,
F: FnMut(<T as FallibleIterator>::Item) -> Result<B, <T as FallibleIterator>::Error>,
type Item = B
type Error = <T as FallibleIterator>::Error
type Item = <I as FallibleIterator>::Item
type Error = <I as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
pub fn last(
self
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
pub fn nth(
&mut self,
n: usize
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
pub fn try_fold<B, E, F>(&mut self, init: B, f: F) -> Result<B, E> where
E: From<<I as FallibleIterator>::Error>,
F: FnMut(B, <I as FallibleIterator>::Item) -> Result<B, E>,
type Item = <I as FallibleIterator>::Item
type Error = <I as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
pub fn nth(
&mut self,
n: usize
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
type Item = <I as FallibleIterator>::Item
type Error = <I as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
pub fn try_fold<B, E, F>(&mut self, init: B, f: F) -> Result<B, E> where
E: From<<I as FallibleIterator>::Error>,
F: FnMut(B, <I as FallibleIterator>::Item) -> Result<B, E>,
type Error = <I as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<(usize, <I as FallibleIterator>::Item)>, <I as FallibleIterator>::Error>
impl<I, F> FallibleIterator for Inspect<I, F> where
F: FnMut(&<I as FallibleIterator>::Item) -> Result<(), <I as FallibleIterator>::Error>,
I: FallibleIterator,
impl<I, F> FallibleIterator for Inspect<I, F> where
F: FnMut(&<I as FallibleIterator>::Item) -> Result<(), <I as FallibleIterator>::Error>,
I: FallibleIterator,
type Item = <I as FallibleIterator>::Item
type Error = <I as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
pub fn try_fold<B, E, G>(&mut self, init: B, f: G) -> Result<B, E> where
E: From<<I as FallibleIterator>::Error>,
G: FnMut(B, <I as FallibleIterator>::Item) -> Result<B, E>,
impl<I, U, F> FallibleIterator for FlatMap<I, U, F> where
F: FnMut(<I as FallibleIterator>::Item) -> Result<U, <I as FallibleIterator>::Error>,
I: FallibleIterator,
U: IntoFallibleIterator<Error = <I as FallibleIterator>::Error>,
impl<I, U, F> FallibleIterator for FlatMap<I, U, F> where
F: FnMut(<I as FallibleIterator>::Item) -> Result<U, <I as FallibleIterator>::Error>,
I: FallibleIterator,
U: IntoFallibleIterator<Error = <I as FallibleIterator>::Error>,
type Item = <U as IntoFallibleIterator>::Item
type Error = <U as IntoFallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<U as IntoFallibleIterator>::Item>, <U as IntoFallibleIterator>::Error>
pub fn try_fold<B, E, G>(&mut self, init: B, f: G) -> Result<B, E> where
E: From<<U as IntoFallibleIterator>::Error>,
G: FnMut(B, <U as IntoFallibleIterator>::Item) -> Result<B, E>,
impl<I, F> FallibleIterator for Filter<I, F> where
F: FnMut(&<I as FallibleIterator>::Item) -> Result<bool, <I as FallibleIterator>::Error>,
I: FallibleIterator,
impl<I, F> FallibleIterator for Filter<I, F> where
F: FnMut(&<I as FallibleIterator>::Item) -> Result<bool, <I as FallibleIterator>::Error>,
I: FallibleIterator,
type Item = <I as FallibleIterator>::Item
type Error = <I as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
pub fn try_fold<B, E, G>(&mut self, init: B, f: G) -> Result<B, E> where
E: From<<I as FallibleIterator>::Error>,
G: FnMut(B, <I as FallibleIterator>::Item) -> Result<B, E>,
impl<I, P> FallibleIterator for TakeWhile<I, P> where
I: FallibleIterator,
P: FnMut(&<I as FallibleIterator>::Item) -> Result<bool, <I as FallibleIterator>::Error>,
impl<I, P> FallibleIterator for TakeWhile<I, P> where
I: FallibleIterator,
P: FnMut(&<I as FallibleIterator>::Item) -> Result<bool, <I as FallibleIterator>::Error>,
impl<B, I, St, F> FallibleIterator for Scan<I, St, F> where
F: FnMut(&mut St, <I as FallibleIterator>::Item) -> Result<Option<B>, <I as FallibleIterator>::Error>,
I: FallibleIterator,
impl<B, I, St, F> FallibleIterator for Scan<I, St, F> where
F: FnMut(&mut St, <I as FallibleIterator>::Item) -> Result<Option<B>, <I as FallibleIterator>::Error>,
I: FallibleIterator,
impl<'a, T, I> FallibleIterator for Cloned<I> where
T: 'a + Clone,
I: FallibleIterator<Item = &'a T>,
impl<'a, T, I> FallibleIterator for Cloned<I> where
T: 'a + Clone,
I: FallibleIterator<Item = &'a T>,
type Item = T
type Error = <I as FallibleIterator>::Error
type Item = <I as FallibleIterator>::Item
type Error = <I as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
pub fn nth(
&mut self,
n: usize
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
impl<T, U> FallibleIterator for Zip<T, U> where
T: FallibleIterator,
U: FallibleIterator<Error = <T as FallibleIterator>::Error>,
impl<T, U> FallibleIterator for Zip<T, U> where
T: FallibleIterator,
U: FallibleIterator<Error = <T as FallibleIterator>::Error>,
type Item = (<T as FallibleIterator>::Item, <U as FallibleIterator>::Item)
type Error = <T as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<(<T as FallibleIterator>::Item, <U as FallibleIterator>::Item)>, <T as FallibleIterator>::Error>
type Item = <I as FallibleIterator>::Item
type Error = <I as FallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<I as FallibleIterator>::Item>, <I as FallibleIterator>::Error>
pub fn try_fold<B, E, F>(&mut self, init: B, f: F) -> Result<B, E> where
E: From<<I as FallibleIterator>::Error>,
F: FnMut(B, <I as FallibleIterator>::Item) -> Result<B, E>,
impl<B, I, F> FallibleIterator for FilterMap<I, F> where
F: FnMut(<I as FallibleIterator>::Item) -> Result<Option<B>, <I as FallibleIterator>::Error>,
I: FallibleIterator,
impl<B, I, F> FallibleIterator for FilterMap<I, F> where
F: FnMut(<I as FallibleIterator>::Item) -> Result<Option<B>, <I as FallibleIterator>::Error>,
I: FallibleIterator,
type Item = B
type Error = <I as FallibleIterator>::Error
impl<B, F, I> FallibleIterator for MapErr<I, F> where
F: FnMut(<I as FallibleIterator>::Error) -> B,
I: FallibleIterator,
impl<B, F, I> FallibleIterator for MapErr<I, F> where
F: FnMut(<I as FallibleIterator>::Error) -> B,
I: FallibleIterator,
type Item = <I as FallibleIterator>::Item
type Error = B
impl<I> FallibleIterator for Flatten<I> where
I: FallibleIterator,
<I as FallibleIterator>::Item: IntoFallibleIterator,
<<I as FallibleIterator>::Item as IntoFallibleIterator>::Error == <I as FallibleIterator>::Error,
impl<I> FallibleIterator for Flatten<I> where
I: FallibleIterator,
<I as FallibleIterator>::Item: IntoFallibleIterator,
<<I as FallibleIterator>::Item as IntoFallibleIterator>::Error == <I as FallibleIterator>::Error,
type Item = <<I as FallibleIterator>::Item as IntoFallibleIterator>::Item
type Error = <<I as FallibleIterator>::Item as IntoFallibleIterator>::Error
pub fn next(
&mut self
) -> Result<Option<<Flatten<I> as FallibleIterator>::Item>, <Flatten<I> as FallibleIterator>::Error>
Implementors
FallibleIterator
implementation for CodesHandle
to access GRIB messages inside file.
To access GRIB messages the ecCodes library uses a method similar to a C-style iterator.
It digests the FILE *
multiple times each time returning the codes_handle
raw pointer
to a message inside the file. This method would be unsafe to expose directly.
Therefore this crate utilizes the Iterator
to provide the access to GRIB messages in
a safe and convienient way.
FallibleIterator
is used instead of classic Iterator
because internal ecCodes functions can return error codes when the GRIB file
is corrupted and for some other reasons. The usage of FallibleIterator
is sligthly different
than usage of Iterator
, check its documentation for more details.
Using the FallibleIterator
is the only way to read KeyedMessage
s from the file.
Its basic usage is simply with while let statement (similar to for loop for classic Iterator
):
let file_path = Path::new("./data/iceland-surface.grib");
let product_kind = ProductKind::GRIB;
let mut handle = CodesHandle::new_from_file(file_path, product_kind).unwrap();
while let Some(message) = handle.next().unwrap() {
let key = message.read_key("name").unwrap();
if let KeyType::Str(name) = key.value {
println!("{:?}", name);
}
}
The FallibleIterator
can be collected to convert the handle into a
Vector
of KeyedMessage
s.
For example:
let file_path = Path::new("./data/iceland-surface.grib");
let product_kind = ProductKind::GRIB;
let handle = CodesHandle::new_from_file(file_path, product_kind).unwrap();
let handle_collected: Vec<KeyedMessage> = handle.collect().unwrap();
Use of filter()
, map()
and other methods provided with Iterator
allow for
more advanced extracting of GRIB messages from the file.
Errors
The next()
method will return CodesInternal
when internal ecCodes function returns non-zero code.
type Item = KeyedMessage
type Error = CodesError
FallibleIterator
implementation for KeyedMessage to access keyes inside message.
Mainly useful to discover what keys are present inside the message.
This function internally calls read_key()
function
so it is probably more efficient to call that function directly only for keys you
are interested in.
FallibleIterator
is used instead of classic Iterator
because internal ecCodes functions can return internal error in some edge-cases.
The usage of FallibleIterator
is sligthly different than usage of Iterator
,
check its documentation for more details.
Example
let file_path = Path::new("./data/iceland.grib");
let product_kind = ProductKind::GRIB;
let mut handle = CodesHandle::new_from_file(file_path, product_kind).unwrap();
let mut current_message = handle.next().unwrap().unwrap();
while let Some(key) = current_message.next().unwrap() {
println!("{:?}", key);
}
Errors
The next()
method will return CodesInternal
when internal ecCodes function returns non-zero code.