[][src]Struct update_channel::Receiver

pub struct Receiver<T> { /* fields omitted */ }

The receiving half of an update channel

This struct holds an internal buffer in which data is held. The buffer can then be updated with recv_update, take_update usw.

Implementations

impl<T> Receiver<T>[src]

pub fn take_update(&mut self) -> Result<Option<T>, ReceiveError>[src]

Takes the new updated value and make it unavailable for all other receivers. Returns the previous value inside the buffer if the value has not been taken by another receiver, otherwise Returns Ok(None)

pub unsafe fn take_update_unsafe(&self) -> Result<Option<T>, ReceiveError>[src]

Same as Receiver::take_update but without borrowing mutably. This might open new possiblities, but it might result in undefined behavior if there are immutable borrows created with Receiver::borrow

pub fn borrow(&self) -> &T[src]

Get the value saved in the internal buffer without updating as borrow

pub fn borrow_mut(&mut self) -> &mut T[src]

Get a mutable reference to the value in the buffer

pub fn into_inner(self) -> T[src]

Unwrap the value contained in the buffer of this receiver

pub fn borrow_locked<'a>(
    &'a self
) -> Result<RwLockReadGuard<'a, Option<T>>, ReceiveError>
[src]

Get the latest value (not the value in the buffer) and return it while holding a read lock to it. It is not recommended to hold on to this lock for long.

pub fn has_updater(&self) -> bool[src]

Checks if at least one updater exists

impl<T> Receiver<T> where
    T: Clone
[src]

pub fn recv_update(&mut self) -> Result<Option<T>, ReceiveError>[src]

Clone the latest updated value into the internal buffer. Returns the previous value inside the buffer if the value has not been taken by another receiver

pub unsafe fn recv_update_unsafe(&self) -> Result<Option<T>, ReceiveError>[src]

Same as Receiver::recv_update but without borrowing mutably. This might open new possiblities, but it might result in undefined behavior if there are immutable borrows created with Receiver::borrow

pub fn get_cloned(&self) -> Result<Option<T>, ReceiveError>[src]

Get the latest value (not the value in the buffer) cloned

impl<T> Receiver<T> where
    T: Clone + PartialEq
[src]

pub fn recv_update_checked(&mut self) -> Result<Option<T>, ReceiveError>[src]

Updates the internal buffer by cloning the updated value if it is different from the current held value

pub unsafe fn recv_update_checked_unsafe(
    &self
) -> Result<Option<T>, ReceiveError>
[src]

Same as Receiver::recv_update_checked but without borrowing mutably. This might open new possiblities, but it might result in undefined behavior if there are immutable borrows created with Receiver::borrow

pub fn take_update_checked(&mut self) -> Result<Option<T>, ReceiveError>[src]

Updates the internal buffer by taking the updated value if it is different from the current held value

pub unsafe fn take_update_checked_unsafe(
    &self
) -> Result<Option<T>, ReceiveError>
[src]

Same as Receiver::recv_update_checked but without borrowing mutably. This might open new possiblities, but it might result in undefined behavior if there are immutable borrows created with Receiver::borrow

Trait Implementations

impl<T> Clone for Receiver<T> where
    T: Clone
[src]

impl<T: Debug> Debug for Receiver<T>[src]

impl<T> Send for Receiver<T> where
    T: Clone
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Receiver<T>[src]

impl<T> !Sync for Receiver<T>[src]

impl<T> Unpin for Receiver<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Receiver<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.