Function grib::from_reader
source · pub fn from_reader<SR: Read + Seek>(
reader: SR,
) -> Result<Grib2<SeekableGrib2Reader<SR>>, GribError>
Expand description
Reads a Grib2
instance from an I/O stream of GRIB2.
§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 result = grib::from_reader(f);
assert!(result.is_ok());
let grib2 = result?;
assert_eq!(grib2.len(), 1);
Ok(())
}