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 Ord for Duration
impl Ord for Duration
source§impl PartialEq<Duration> for &Duration
impl PartialEq<Duration> for &Duration
source§impl PartialEq<Duration> for &Duration
impl PartialEq<Duration> for &Duration
source§impl PartialEq<Duration> for Duration
impl PartialEq<Duration> for Duration
source§impl PartialEq<Duration> for Duration
impl PartialEq<Duration> for Duration
source§impl PartialEq for Duration
impl PartialEq for Duration
source§impl PartialOrd<Duration> for Duration
impl PartialOrd<Duration> for Duration
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl PartialOrd for Duration
impl PartialOrd for Duration
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more