pub struct Duration { /* private fields */ }Expand description
Duration type representing a time interval in seconds.
Used for configuring timeouts, wait operations, and other time-based settings.
§Example
use durable_execution_sdk::Duration;
let five_seconds = Duration::from_seconds(5);
let two_minutes = Duration::from_minutes(2);
let one_hour = Duration::from_hours(1);
let one_day = Duration::from_days(1);
let one_week = Duration::from_weeks(1);
let one_month = Duration::from_months(1);
let one_year = Duration::from_years(1);
assert_eq!(five_seconds.to_seconds(), 5);
assert_eq!(two_minutes.to_seconds(), 120);
assert_eq!(one_hour.to_seconds(), 3600);
assert_eq!(one_day.to_seconds(), 86400);
assert_eq!(one_week.to_seconds(), 604800);
assert_eq!(one_month.to_seconds(), 2592000); // 30 days
assert_eq!(one_year.to_seconds(), 31536000); // 365 daysImplementations§
Source§impl Duration
impl Duration
Sourcepub fn from_seconds(seconds: u64) -> Duration
pub fn from_seconds(seconds: u64) -> Duration
Sourcepub fn from_minutes(minutes: u64) -> Duration
pub fn from_minutes(minutes: u64) -> Duration
Sourcepub fn from_hours(hours: u64) -> Duration
pub fn from_hours(hours: u64) -> Duration
Sourcepub fn from_weeks(weeks: u64) -> Duration
pub fn from_weeks(weeks: u64) -> Duration
Sourcepub fn from_months(months: u64) -> Duration
pub fn from_months(months: u64) -> Duration
Creates a new Duration from the given number of months.
A month is defined as 30 days for consistency.
§Arguments
months- The number of months for this duration
§Example
use durable_execution_sdk::Duration;
let duration = Duration::from_months(1);
assert_eq!(duration.to_seconds(), 2592000); // 30 daysSourcepub fn from_years(years: u64) -> Duration
pub fn from_years(years: u64) -> Duration
Creates a new Duration from the given number of years.
A year is defined as 365 days for consistency.
§Arguments
years- The number of years for this duration
§Example
use durable_execution_sdk::Duration;
let duration = Duration::from_years(1);
assert_eq!(duration.to_seconds(), 31536000); // 365 daysSourcepub fn to_seconds(&self) -> u64
pub fn to_seconds(&self) -> u64
Returns the total number of seconds in this duration.
§Example
use durable_execution_sdk::Duration;
let duration = Duration::from_minutes(2);
assert_eq!(duration.to_seconds(), 120);Sourcepub fn validate_for_wait(&self) -> Result<(), DurableError>
pub fn validate_for_wait(&self) -> Result<(), DurableError>
Validates that this duration is at least the minimum required for wait operations.
Wait operations require a minimum duration of 1 second.
§Returns
Ok(())if the duration is valid (>= 1 second)Err(DurableError::Validation)if the duration is less than 1 second
§Example
use durable_execution_sdk::Duration;
let valid = Duration::from_seconds(1);
assert!(valid.validate_for_wait().is_ok());
let invalid = Duration::from_seconds(0);
assert!(invalid.validate_for_wait().is_err());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Duration, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Duration, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Duration
impl Ord for Duration
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
Source§impl Serialize for Duration
impl Serialize for Duration
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 Copy for Duration
impl Eq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnsafeUnpin for Duration
impl UnwindSafe for Duration
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<B> IntoFunctionResponse<B, Body> for Bwhere
B: Serialize,
impl<B> IntoFunctionResponse<B, Body> for Bwhere
B: Serialize,
Source§fn into_response(self) -> FunctionResponse<B, Body>
fn into_response(self) -> FunctionResponse<B, Body>
Convert the type into a FunctionResponse.
Creates a shared type from an unshared type.