Skip to main content

Resolution

Enum Resolution 

Source
pub enum Resolution {
    Minutes(MinuteStep),
    Hour,
    Day,
    Month,
    Year,
}
Expand description

The length of one interval of a metered series.

The string form is an ISO 8601 duration (PT15M, PT1H, P1D, P1M, P1Y), written by Display, read by FromStr and used on the serde wire.

Variants§

§

Minutes(MinuteStep)

A fixed step of whole minutes dividing the hour.

§

Hour

One hour (3 600 s) — the gas settlement slot.

§

Day

One Berlin calendar day (or Gastag) — 23 h, 24 h or 25 h.

§

Month

One Berlin calendar month.

§

Year

One Berlin calendar year.

Implementations§

Source§

impl Resolution

Source

pub const QUARTER_HOUR: Self

15 minutes — the German electricity settlement slot (RLM, iMSys).

Source

pub const HALF_HOUR: Self

30 minutes.

Source

pub const fn minutes(minutes: u8) -> Option<Self>

A minute resolution; Some(Hour) for 60, None unless minutes divides 60.

Source

pub const fn fixed_seconds(self) -> Option<u32>

The interval length in seconds, when it is the same on every date; None for Day, Month and Year, whose lengths depend on the calendar and on DST.

Source

pub const fn nominal_seconds(self) -> u32

A nominal length in seconds, for ordering and sizing only — Day is 24 h, Month 30 days, Year 365 days. Not for counts or billing.

Source

pub const fn is_fixed(self) -> bool

true for the fixed-length group: Minutes and Hour.

Source

pub const fn is_calendar(self) -> bool

true for the calendar group: Day, Month, Year.

Source

pub const fn is_subhourly(self) -> bool

true for every step shorter than an hour.

Source

pub const fn label(self) -> &'static str

Human-readable German label.

Source

pub const fn from_seconds(secs: u32) -> Option<Self>

The fixed resolution of exactly secs seconds, if one exists; never Day, Month or Year.

Source

pub fn from_observed_seconds(secs: i64) -> Option<Self>

The resolution an observed spacing of secs seconds indicates.

A fixed step matches within ±5 %; a day matches 23–25 h, a month 28 days − 1 h to 31 days + 1 h, a year 365 days − 1 h to 366 days + 1 h.

use metering::Resolution;

assert_eq!(Resolution::from_observed_seconds(898), Some(Resolution::QUARTER_HOUR));
assert_eq!(Resolution::from_observed_seconds(90_000), Some(Resolution::Day));
// March: 31 days minus the spring-forward hour.
assert_eq!(Resolution::from_observed_seconds(31 * 86_400 - 3_600), Some(Resolution::Month));
assert_eq!(Resolution::from_observed_seconds(366 * 86_400), Some(Resolution::Year));
assert_eq!(Resolution::from_observed_seconds(7_200), None);
assert_eq!(Resolution::from_observed_seconds(0), None);

Trait Implementations§

Source§

impl Clone for Resolution

Source§

fn clone(&self) -> Self

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 Copy for Resolution

Source§

impl Debug for Resolution

Source§

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

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

impl<'de> Deserialize<'de> for Resolution

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Resolution

Source§

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

Writes the ISO 8601 duration form, which FromStr reads back.

Source§

impl Eq for Resolution

Source§

impl FromStr for Resolution

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses PT{n}S, PT{n}M, PT{n}H, P1D, P1M and P1Y, case-insensitively and trimmed; fixed forms are normalised (PT900S and PT60M read as PT15M/PT1H).

§Errors

Charset for a malformed string, Range for a well-formed duration outside the set.

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

impl Hash for Resolution

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Resolution

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Resolution

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Writes the Display string.

Source§

impl StructuralPartialEq for Resolution

Auto Trait Implementations§

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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.