Struct grib::Grib2SubmessageDecoder
source · pub struct Grib2SubmessageDecoder { /* private fields */ }
Expand description
Decoder for grid point values of GRIB2 submessages.
§Examples
use grib::Grib2SubmessageDecoder;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let f =
std::fs::File::open("testdata/CMC_glb_TMP_ISBL_1_latlon.24x.24_2021051800_P000.grib2")?;
let f = std::io::BufReader::new(f);
let grib2 = grib::from_reader(f)?;
let (_index, first_submessage) = grib2.iter().next().unwrap();
let decoder = Grib2SubmessageDecoder::from(first_submessage)?;
let mut decoded = decoder.dispatch()?;
assert_eq!(decoded.size_hint(), (1126500, Some(1126500)));
let first_value = decoded.next();
assert_eq!(first_value.map(|f| f.round()), Some(236.0_f32));
let last_value = decoded.nth(1126498);
assert_eq!(last_value.map(|f| f.round()), Some(286.0_f32));
let next_to_last_value = decoded.next();
assert_eq!(next_to_last_value, None);
Ok(())
}
Implementations§
source§impl Grib2SubmessageDecoder
impl Grib2SubmessageDecoder
Auto Trait Implementations§
impl Freeze for Grib2SubmessageDecoder
impl RefUnwindSafe for Grib2SubmessageDecoder
impl Send for Grib2SubmessageDecoder
impl Sync for Grib2SubmessageDecoder
impl Unpin for Grib2SubmessageDecoder
impl UnwindSafe for Grib2SubmessageDecoder
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
Mutably borrows from an owned value. Read more