Struct simple_left_right::Writer

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

Not realtime safe Object which can change the internal T value

Implementations§

source§

impl<T, O> Writer<T, O>

source

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

get a Reader if none exists

source

pub fn read(&self) -> &T

The Value returned may be newer than the version the reader is currently seeing. This value will be written to next.

source§

impl<T: Absorb<O>, O> Writer<T, O>

source

pub fn lock(&mut self) -> WriteGuard<'_, T, O>

Blocks if the Reader has a ReadGuard pointing to the old value.

Uses a Spinlock because for anything else the OS needs to be involved. Reader can’t talk to the OS.

source

pub fn try_lock(&mut self) -> Option<WriteGuard<'_, T, O>>

doesn’t block. Returns None if the Reader has a ReadGuard pointing to the old value

source§

impl<T: Clone, O> Writer<T, O>

source

pub fn new(value: T) -> Self

Creates a new Writer by cloning the value once to get two values

Trait Implementations§

source§

impl<T: Debug, O: Debug> Debug for Writer<T, O>

source§

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

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

impl<T: Default, O> Default for Writer<T, O>

source§

fn default() -> Self

Creates a new Writer by calling T::default() twice to create the two values

Default impl of T needs to give the same result every time. Doesn’t lead to UB, but turns the library basically useless

Auto Trait Implementations§

§

impl<T, O> Freeze for Writer<T, O>

§

impl<T, O> !RefUnwindSafe for Writer<T, O>

§

impl<T, O> Send for Writer<T, O>
where T: Send + Sync, O: Send,

§

impl<T, O> Sync for Writer<T, O>
where T: Send + Sync, O: Sync,

§

impl<T, O> Unpin for Writer<T, O>
where O: Unpin,

§

impl<T, O> !UnwindSafe for Writer<T, O>

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.