Struct grib::Grib2

source ·
pub struct Grib2<R> { /* private fields */ }

Implementations§

source§

impl<R> Grib2<R>

source

pub fn len(&self) -> usize

Returns the length of submessages in the data.

§Examples
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let f = std::fs::File::open(
        "testdata/icon_global_icosahedral_single-level_2021112018_000_TOT_PREC.grib2",
    )?;
    let f = std::io::BufReader::new(f);
    let grib2 = grib::from_reader(f)?;

    assert_eq!(grib2.len(), 1);
    Ok(())
}
source

pub fn is_empty(&self) -> bool

Returns true if self has zero submessages.

source

pub fn iter(&self) -> SubmessageIterator<'_, R>

Returns an iterator over submessages in the data.

§Examples
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let f = std::fs::File::open(
        "testdata/icon_global_icosahedral_single-level_2021112018_000_TOT_PREC.grib2",
    )?;
    let f = std::io::BufReader::new(f);
    let grib2 = grib::from_reader(f)?;

    let mut iter = grib2.iter();
    let first = iter.next();
    assert!(first.is_some());

    let first = first.unwrap();
    let (message_index, _) = first;
    assert_eq!(message_index, (0, 0));

    let second = iter.next();
    assert!(second.is_none());
    Ok(())
}
source

pub fn submessages(&self) -> SubmessageIterator<'_, R>

Returns an iterator over submessages in the data.

This is an alias to Grib2::iter().

source

pub fn sections(&self) -> Iter<'_, SectionInfo>

Returns an iterator over sections in the data.

§Examples
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let f = std::fs::File::open(
        "testdata/icon_global_icosahedral_single-level_2021112018_000_TOT_PREC.grib2",
    )?;
    let f = std::io::BufReader::new(f);
    let grib2 = grib::from_reader(f)?;

    let mut iter = grib2.sections();
    let first = iter.next();
    assert!(first.is_some());

    let first = first.unwrap();
    assert_eq!(first.num, 0);

    let tenth = iter.nth(9);
    assert!(tenth.is_none());
    Ok(())
}
source§

impl<R: Grib2Read> Grib2<R>

Trait Implementations§

source§

impl<'a, R: 'a> IntoIterator for &'a Grib2<R>

§

type Item = ((usize, usize), SubMessage<'a, R>)

The type of the elements being iterated over.
§

type IntoIter = SubmessageIterator<'a, R>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<R> !Freeze for Grib2<R>

§

impl<R> !RefUnwindSafe for Grib2<R>

§

impl<R> Send for Grib2<R>
where R: Send,

§

impl<R> !Sync for Grib2<R>

§

impl<R> Unpin for Grib2<R>
where R: Unpin,

§

impl<R> UnwindSafe for Grib2<R>
where R: UnwindSafe,

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<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.