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.