Value

Struct Value 

Source
pub struct Value<T> { /* private fields */ }

Implementations§

Source§

impl<T: Send + Sync + 'static> Value<T>

Source

pub fn new() -> Self

Source

pub fn new_arc() -> Arc<Self>

Source

pub fn write(&self, item: T)

Source

pub fn write_and_tick(&self, item: T)

Source

pub fn write_if_changed(&self, item: T)
where T: PartialEq,

Source

pub fn write_if_changed_and_tick(&self, item: T)
where T: PartialEq,

Source

pub fn read(&self) -> Option<T>
where T: Clone,

Read a value if changed.

Source

pub fn force_read(&self) -> Option<T>
where T: Clone,

Read and ignore change detection, this always reads a value if initialized.

Source

pub fn read_async(&self) -> impl FusedFuture<Output = T> + Unpin + '_
where T: Clone,

Read a value once changed asynchronously.

Source

pub fn read_async_owned( self, ) -> impl FusedFuture<Output = (T, Self)> + Unpin + 'static
where T: Clone,

Read a value once changed asynchronously.

Source

pub fn read_async_arc( self: Arc<Self>, ) -> impl FusedFuture<Output = T> + Unpin + 'static
where T: Clone,

Read a value once changed asynchronously.

Source

pub fn make_readable(&self)

Rewind the tick to make the underlying value readable.

Source

pub fn clone_uninit(&self) -> Self

Clone and duplicate the read tick, this makes the current value unreadable.

Source

pub fn clone_init(&self) -> Self

Clone and decrement the read tick, this makes the current value always readable.

Source

pub fn clone_raw(&self) -> Self

The real Clone implementation that does not guarantee value is readable.

Clone is not implemented since we primarily want to use Arc::clone with this type.

Source

pub fn into_arc(self) -> Arc<Self>

Convert into Arc<Value<T>>.

Source

pub fn to_stream(&self) -> impl FusedStream<Item = T> + Unpin + '_
where T: Clone,

Source

pub fn into_stream(self) -> impl FusedStream<Item = T> + Unpin
where T: Clone,

Source

pub fn into_stream_arc(self: Arc<Self>) -> impl FusedStream<Item = T> + Unpin
where T: Clone,

Trait Implementations§

Source§

impl<T: Debug> Debug for Value<T>

Source§

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

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

impl<T: Send + Sync + 'static> Default for Value<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for Value<T>

§

impl<T> RefUnwindSafe for Value<T>

§

impl<T> Send for Value<T>
where T: Send + Sync,

§

impl<T> Sync for Value<T>
where T: Send + Sync,

§

impl<T> Unpin for Value<T>

§

impl<T> UnwindSafe for Value<T>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.