pub struct SerialisedAsMillis(/* private fields */);Expand description
A newtype wrapper meant to facilitate encoding of time::Duration as integers with millis precision. This may seem odd, but is necessary to mimicks the encoding behavior of some Haskell types such as ‘SlotLength’.
Note that there is a loss of precision coming from this type when durations are below milliseconds. In practice, this type is used to represent seconds or tenth of seconds.
Implementations§
Source§impl SerialisedAsMillis
impl SerialisedAsMillis
pub fn deserialize<'de, D>(deserializer: D) -> Result<Duration, D::Error>where
D: Deserializer<'de>,
pub fn serialize<S>(
duration: &Duration,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
Trait Implementations§
Source§impl Debug for SerialisedAsMillis
impl Debug for SerialisedAsMillis
Source§impl<'b, C> Decode<'b, C> for SerialisedAsMillis
impl<'b, C> Decode<'b, C> for SerialisedAsMillis
Source§impl<C> Encode<C> for SerialisedAsMillis
impl<C> Encode<C> for SerialisedAsMillis
Source§impl From<Duration> for SerialisedAsMillis
impl From<Duration> for SerialisedAsMillis
Source§impl From<SerialisedAsMillis> for Duration
impl From<SerialisedAsMillis> for Duration
Source§fn from(t: SerialisedAsMillis) -> Self
fn from(t: SerialisedAsMillis) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for SerialisedAsMillis
impl RefUnwindSafe for SerialisedAsMillis
impl Send for SerialisedAsMillis
impl Sync for SerialisedAsMillis
impl Unpin for SerialisedAsMillis
impl UnsafeUnpin for SerialisedAsMillis
impl UnwindSafe for SerialisedAsMillis
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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