Struct 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§

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

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 T::clone() shoulnd’t give a different value, as that would make this library pretty useless

Source§

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

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. If this is called after swapping the write_lock this will return an older value. To get the newest value lock the writer and call Writeguard::read.

Needs T: Sync because maybe this is the value the reader is curently reading

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. Not upholding this doens’t lead to UB, but turns the library basically useless

Source§

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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

SAFETY: owns T and O

Source§

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

SAFETY: &self fn can only create a &T and never gives shared access to O

Auto Trait Implementations§

§

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

§

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

§

impl<T, O> Unpin for Writer<T, O>
where O: Unpin, T: 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.