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.
Duration
s can be compared with std::time::Duration
s. If the
Duration
is negative, it will always be considered less than the
std::time::Duration
. Similarly, because std::time::Duration
s 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 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)