pub enum Resolution {
Minutes(MinuteStep),
Hour,
Day,
Month,
Year,
}Expand description
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
impl Resolution
Sourcepub const QUARTER_HOUR: Self
pub const QUARTER_HOUR: Self
15 minutes — the German electricity settlement slot (RLM, iMSys).
Sourcepub const fn minutes(minutes: u8) -> Option<Self>
pub const fn minutes(minutes: u8) -> Option<Self>
A minute resolution; Some(Hour) for 60, None unless minutes
divides 60.
Sourcepub const fn fixed_seconds(self) -> Option<u32>
pub const fn fixed_seconds(self) -> Option<u32>
Sourcepub const fn nominal_seconds(self) -> u32
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.
Sourcepub const fn is_calendar(self) -> bool
pub const fn is_calendar(self) -> bool
true for the calendar group: Day, Month, Year.
Sourcepub const fn is_subhourly(self) -> bool
pub const fn is_subhourly(self) -> bool
true for every step shorter than an hour.
Sourcepub const fn from_seconds(secs: u32) -> Option<Self>
pub const fn from_seconds(secs: u32) -> Option<Self>
The fixed resolution of exactly secs seconds, if one exists; never
Day, Month or Year.
Sourcepub fn from_observed_seconds(secs: i64) -> Option<Self>
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
impl Clone for Resolution
impl Copy for Resolution
Source§impl Debug for Resolution
impl Debug for Resolution
Source§impl<'de> Deserialize<'de> for Resolution
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Resolution
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for Resolution
impl Display for Resolution
impl Eq for Resolution
Source§impl FromStr for Resolution
impl FromStr for Resolution
Source§impl Hash for Resolution
impl Hash for Resolution
Source§impl PartialEq for Resolution
impl PartialEq for Resolution
Source§impl Serialize for Resolution
Available on crate feature serde only.
impl Serialize for Resolution
serde only.