Struct TcReader

Source
pub struct TcReader<T, M>
where T: TakesMessage<M>,
{ /* private fields */ }
Expand description

TcReader<T,M> maintains its local T object. The reader will receive and apply incoming M messages to its T whenever explicitly invoked by update, update_limited or implicity by get_mut_fresh.

Access to the local copy is granted through the two get_mut variants. Without any messages, this local access is very fast. The reader can also be consumed to unwrap the local T.

The very explicit convention of using stale and fresh everywhere is to make unintentionally forgetting a crucial update less likely.

Implementations§

Source§

impl<T, M> TcReader<T, M>
where T: TakesMessage<M>, M: Sync + Clone,

Source

pub fn update(&mut self) -> usize

Receives all waiting messages and applies them to the local object.

Source

pub fn update_return(&mut self) -> Vec<M>

Receives any waiting messages up to a limit. collects and returns these messages in a vector.

Source

pub fn update_limited(&mut self, limit: usize) -> usize

Receives any waiting messages up to a limit. Returns number of messages received and applied.

Source

pub fn update_return_limited(&mut self, limit: usize) -> Vec<M>

combination of update_return and update_limited

Source

pub fn into_inner(self) -> T

Consumes the reader, returning the current version of the trailing T.

Trait Implementations§

Source§

impl<T, M> Deref for TcReader<T, M>
where T: TakesMessage<M>,

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T, M> DerefMut for TcReader<T, M>
where T: TakesMessage<M>,

Source§

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

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<T, M> Freeze for TcReader<T, M>
where T: Freeze,

§

impl<T, M> !RefUnwindSafe for TcReader<T, M>

§

impl<T, M> Send for TcReader<T, M>
where T: Send, M: Send,

§

impl<T, M> Sync for TcReader<T, M>
where T: Sync, M: Send,

§

impl<T, M> Unpin for TcReader<T, M>
where T: Unpin,

§

impl<T, M> !UnwindSafe for TcReader<T, M>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.