pub struct Duration { /* private fields */ }Expand description
A Kubernetes duration.
This is equivalent to the metav1.Duration type in the Go Kubernetes
apimachinery package. A metav1.Duration is serialized in YAML and JSON
as a string formatted in the format accepted by the Go standard library’s
time.ParseDuration() function. This type is a similar wrapper around
Rust’s std::time::Duration that can be serialized and deserialized using
the same format as metav1.Duration.
§On Signedness
Go’s time.Duration type is a signed integer type, while Rust’s
std::time::Duration is unsigned. Therefore, this type is also capable of
representing both positive and negative durations. This is implemented by
storing whether or not the parsed duration was negative as a boolean field
in the wrapper type. The Duration::is_negative method returns this
value, and when a Duration is serialized, the negative sign is included
if the duration is negative.
Durations can be compared with std::time::Durations. If the
Duration is negative, it will always be considered less than the
std::time::Duration. Similarly, because std::time::Durations are
unsigned, a negative Duration will never be equal to a
std::time::Duration, even if the wrapped std::time::Duration (the
negative duration’s absolute value) is equal.
When converting a Duration into a std::time::Duration, be aware that
this information is lost: if a negative Duration is converted into a
std::time::Duration and then that std::time::Duration is converted
back into a Duration, the second Duration will not be negative.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl JsonSchema for Duration
impl JsonSchema for Duration
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§fn json_schema(_: &mut SchemaGenerator) -> Schema
fn json_schema(_: &mut SchemaGenerator) -> Schema
Source§impl Ord for Duration
impl Ord for Duration
Source§impl PartialOrd<Duration> for Duration
impl PartialOrd<Duration> for Duration
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
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 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
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.