pub enum CostPeriod {
Day,
Month,
}Expand description
Calendar period, in UTC, over which the cost of a role is counted.
§Examples
use std::str::FromStr;
use ironflow_core::agent_role::CostPeriod;
assert_eq!(CostPeriod::from_str("day").ok(), Some(CostPeriod::Day));
assert_eq!(CostPeriod::Month.to_string(), "month");Variants§
Day
From midnight UTC to the next midnight UTC.
Month
From the 1st of the month at 00:00 UTC to the 1st of the next month.
Implementations§
Source§impl CostPeriod
impl CostPeriod
Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
Stable name of the period, as stored and sent over the API.
§Examples
use ironflow_core::agent_role::CostPeriod;
assert_eq!(CostPeriod::Day.as_str(), "day");Sourcepub fn start(self, now: DateTime<Utc>) -> DateTime<Utc>
pub fn start(self, now: DateTime<Utc>) -> DateTime<Utc>
Start of the period containing now.
§Examples
use chrono::{TimeZone, Utc};
use ironflow_core::agent_role::CostPeriod;
let now = Utc.with_ymd_and_hms(2026, 7, 26, 15, 30, 0).unwrap();
assert_eq!(CostPeriod::Day.start(now), Utc.with_ymd_and_hms(2026, 7, 26, 0, 0, 0).unwrap());§Panics
Never panics for a valid DateTime<Utc>: midnight of an existing day
is always unambiguous in UTC.
Sourcepub fn next_start(self, now: DateTime<Utc>) -> DateTime<Utc>
pub fn next_start(self, now: DateTime<Utc>) -> DateTime<Utc>
Start of the period following the one containing now: when the
counter resets.
§Examples
use chrono::{TimeZone, Utc};
use ironflow_core::agent_role::CostPeriod;
let now = Utc.with_ymd_and_hms(2026, 12, 26, 15, 30, 0).unwrap();
assert_eq!(
CostPeriod::Month.next_start(now),
Utc.with_ymd_and_hms(2027, 1, 1, 0, 0, 0).unwrap()
);§Panics
Panics only past the last date chrono represents (year 262143).
Trait Implementations§
Source§impl Clone for CostPeriod
impl Clone for CostPeriod
Source§fn clone(&self) -> CostPeriod
fn clone(&self) -> CostPeriod
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for CostPeriod
Source§impl Debug for CostPeriod
impl Debug for CostPeriod
Source§impl<'de> Deserialize<'de> for CostPeriod
impl<'de> Deserialize<'de> for CostPeriod
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CostPeriod, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CostPeriod, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for CostPeriod
impl Display for CostPeriod
impl Eq for CostPeriod
Source§impl FromStr for CostPeriod
impl FromStr for CostPeriod
Source§type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
Source§fn from_str(s: &str) -> Result<CostPeriod, <CostPeriod as FromStr>::Err>
fn from_str(s: &str) -> Result<CostPeriod, <CostPeriod as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl Hash for CostPeriod
impl Hash for CostPeriod
Source§impl PartialEq for CostPeriod
impl PartialEq for CostPeriod
Source§impl Serialize for CostPeriod
impl Serialize for CostPeriod
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for CostPeriod
Source§impl TryFrom<&str> for CostPeriod
impl TryFrom<&str> for CostPeriod
Source§type Error = ParseError
type Error = ParseError
The type returned in the event of a conversion error.
Source§fn try_from(s: &str) -> Result<CostPeriod, <CostPeriod as TryFrom<&str>>::Error>
fn try_from(s: &str) -> Result<CostPeriod, <CostPeriod as TryFrom<&str>>::Error>
Performs the conversion.
Auto Trait Implementations§
impl Freeze for CostPeriod
impl RefUnwindSafe for CostPeriod
impl Send for CostPeriod
impl Sync for CostPeriod
impl Unpin for CostPeriod
impl UnsafeUnpin for CostPeriod
impl UnwindSafe for CostPeriod
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.