pub struct UpDuration(/* private fields */);Expand description
A duration from the Flockfile grammar ^\d+(h|m|s)?$
Plain digits are milliseconds; s/m/h are seconds/minutes/hours.
Used for min_uptime, kill_timeout, and the other lifecycle timers.
§Example
use shep_core::values::UpDuration;
assert_eq!("30s".parse::<UpDuration>()?.as_millis(), 30_000);
assert!("30S".parse::<UpDuration>().is_err()); // lowercase units onlyImplementations§
Source§impl UpDuration
impl UpDuration
Sourcepub const fn from_millis(ms: u64) -> Self
pub const fn from_millis(ms: u64) -> Self
Wraps a raw millisecond count
Sourcepub const fn as_duration(self) -> Duration
pub const fn as_duration(self) -> Duration
Returns the wrapped core::time::Duration
Trait Implementations§
Source§impl Clone for UpDuration
impl Clone for UpDuration
Source§fn clone(&self) -> UpDuration
fn clone(&self) -> UpDuration
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 UpDuration
Source§impl Debug for UpDuration
impl Debug for UpDuration
Source§impl<'de> Deserialize<'de> for UpDuration
impl<'de> Deserialize<'de> for UpDuration
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
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 UpDuration
Formats with the largest unit dividing the value exactly (ms as digits)
impl Display for UpDuration
Formats with the largest unit dividing the value exactly (ms as digits)
impl Eq for UpDuration
Source§impl FromStr for UpDuration
impl FromStr for UpDuration
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses ^\d+(h|m|s)?$ — plain digits are milliseconds
§Errors
ParseUpDurationError::Empty— empty input.ParseUpDurationError::MissingDigits— unit with no digits.ParseUpDurationError::InvalidCharacter— anything outside ASCII digits plus one trailing lowercaseh/m/s.ParseUpDurationError::Overflow— milliseconds overflowu64.
Source§type Err = ParseUpDurationError
type Err = ParseUpDurationError
The associated error which can be returned from parsing.
Source§impl Hash for UpDuration
impl Hash for UpDuration
Source§impl JsonSchema for UpDuration
Available on crate feature schema only.String-shaped, matching this type’s Serialize/Deserialize — see
MemSize’s own JsonSchema impl for the full reasoning, which applies
here unchanged.
impl JsonSchema for UpDuration
Available on crate feature
schema only.String-shaped, matching this type’s Serialize/Deserialize — see
MemSize’s own JsonSchema impl for the full reasoning, which applies
here unchanged.
Source§fn json_schema(_: &mut SchemaGenerator) -> Schema
fn json_schema(_: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Ord for UpDuration
impl Ord for UpDuration
Source§fn cmp(&self, other: &UpDuration) -> Ordering
fn cmp(&self, other: &UpDuration) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for UpDuration
impl PartialEq for UpDuration
Source§impl PartialOrd for UpDuration
impl PartialOrd for UpDuration
Source§impl Serialize for UpDuration
impl Serialize for UpDuration
impl StructuralPartialEq for UpDuration
Auto Trait Implementations§
impl Freeze for UpDuration
impl RefUnwindSafe for UpDuration
impl Send for UpDuration
impl Sync for UpDuration
impl Unpin for UpDuration
impl UnsafeUnpin for UpDuration
impl UnwindSafe for UpDuration
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
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.