Struct timed_option::TimedOption

source ·
pub struct TimedOption<T, Ttl> { /* private fields */ }
Expand description

Implementations§

source§

impl<T, B> TimedOption<T, B>
where B: TtlBackend,

source

pub fn new(value: T, ttl: B::Duration) -> Self

Some value of type T with a ttl.

source

pub fn into_option(self) -> Option<T>

Returns an Option<T>. If the value is some but expired a None is returned.

source

pub fn as_option(&self) -> Option<&T>

Returns an Option<&T>. If the value is some but expired a None is returned.

source

pub fn into_timed_value(self) -> TimedValue<T>

Returns an TimedValue<T>.

source

pub fn as_timed_value(&self) -> TimedValue<&T>

Returns an TimedValue<&T>.

source

pub fn as_ref(&self) -> TimedOption<&T, B>

Converts from &TimedOption<T> to TimedOption<&T>.

source

pub fn expire(&mut self)

Expires the current ttl.

source

pub fn clear(&mut self)

Sets value to None.

source

pub fn take(&mut self) -> Option<T>

Takes the value out of the TimedOption, returning an Option and leaving a None in its place.

source

pub fn take_timed_value(&mut self) -> TimedValue<T>

Takes the value out of the TimedOption, Returning a TimedValue and leaving a None in its place.

source

pub fn is_some(&self) -> bool

Returns true if the timed-option is Some value and has not expired.

source

pub fn is_none(&self) -> bool

Returns true if the timed-option is None value or it has expired.

Trait Implementations§

source§

impl<T: Clone, Ttl: Clone> Clone for TimedOption<T, Ttl>

source§

fn clone(&self) -> TimedOption<T, Ttl>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug, Ttl: Debug> Debug for TimedOption<T, Ttl>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, B> From<TimedOption<T, B>> for Option<T>
where B: TtlBackend,

source§

fn from(value: TimedOption<T, B>) -> Self

Converts to this type from the input type.
source§

impl<T, B> From<TimedOption<T, B>> for TimedValue<T>
where B: TtlBackend,

source§

fn from(value: TimedOption<T, B>) -> Self

Converts to this type from the input type.
source§

impl<T: Copy, Ttl: Copy> Copy for TimedOption<T, Ttl>

Auto Trait Implementations§

§

impl<T, Ttl> Freeze for TimedOption<T, Ttl>
where Ttl: Freeze, T: Freeze,

§

impl<T, Ttl> RefUnwindSafe for TimedOption<T, Ttl>

§

impl<T, Ttl> Send for TimedOption<T, Ttl>
where Ttl: Send, T: Send,

§

impl<T, Ttl> Sync for TimedOption<T, Ttl>
where Ttl: Sync, T: Sync,

§

impl<T, Ttl> Unpin for TimedOption<T, Ttl>
where Ttl: Unpin, T: Unpin,

§

impl<T, Ttl> UnwindSafe for TimedOption<T, Ttl>
where Ttl: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.