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<Duration, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Duration, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl JsonSchema for Duration
impl JsonSchema for Duration
source§fn schema_name() -> String
fn schema_name() -> String
source§fn is_referenceable() -> bool
fn is_referenceable() -> 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
source§impl Serialize for Duration
impl Serialize for Duration
source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
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
)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§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.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more