Skip to main content

Field

Struct Field 

Source
#[non_exhaustive]
pub struct Field<'a> { pub message: usize, pub discipline: u8, pub center: u16, pub reference_time: ReferenceTime, pub grid: Grid, pub product: Product, pub packing: Packing, /* private fields */ }
Expand description

One field of a GRIB2 file: its headers, with its bitmap and packed values borrowed from the file’s bytes.

It holds no serde derive, since it borrows; its parts (Grid, Product and the others) do.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§message: usize

The message it is in, from 0.

§discipline: u8

The discipline (code table 0.0): 0 meteorological products.

§center: u16

The originating center (common code table C-11): 7 is NCEP.

§reference_time: ReferenceTime

The reference time.

§grid: Grid

The grid.

§product: Product

What the field is.

§packing: Packing

How it is packed.

Implementations§

Source§

impl Field<'_>

Source

pub fn points(&self) -> u64

The grid’s points, ni · nj.

Source

pub fn value(&self, index: u64) -> Result<Option<f64>, Grib2Error>

The value at grid point index (numbered as on Grid), or None where the field has none there. A complex-packed field’s values can only be read in order, so this reads it from its start up to the point, and a JPEG 2000 field’s image is decoded whole: for more than a few points, use Field::values_at or Field::values, which read it once.

§Errors

Grib2Error::PointOutside when index is not below Field::points, and Grib2Error::Malformed when a complex-packed field’s differences overflow or a JPEG 2000 codestream does not decode to the field’s values.

Source

pub fn values_at(&self, indices: &[u64]) -> Result<Vec<Option<f64>>, Grib2Error>

The values at several grid points, in the order asked, reading a complex-packed field once up to the last of them.

§Errors

As Field::value.

Source

pub fn values(&self) -> Result<Vec<Option<f64>>, Grib2Error>

Every grid point’s value, in grid order; None where the field has none. It allocates 16 bytes a point, up to 256 MiB at MAX_POINTS, even for a field of 0 bits in a tiny file; decoding a JPEG 2000 image takes more while it runs.

§Errors

Grib2Error::Malformed when a complex-packed field’s differences overflow or a JPEG 2000 codestream does not decode to the field’s values.

Trait Implementations§

Source§

impl<'a> Clone for Field<'a>

Source§

fn clone(&self) -> Field<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Field<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Field<'a>

Source§

fn eq(&self, other: &Field<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for Field<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Field<'a>

§

impl<'a> RefUnwindSafe for Field<'a>

§

impl<'a> Send for Field<'a>

§

impl<'a> Sync for Field<'a>

§

impl<'a> Unpin for Field<'a>

§

impl<'a> UnsafeUnpin for Field<'a>

§

impl<'a> UnwindSafe for Field<'a>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.