Cell

Struct Cell 

Source
pub struct Cell<S: Signal>(/* private fields */);
Expand description

A wrapper around UnsafeCell, which allows us to reference a signal that might be modified.

For safety reasons, we don’t allow access to the pointer &mut S. Instead, the signal must be read using the Signal methods, and modified using Cell::modify.

Implementations§

Source§

impl<S: Signal> Cell<S>

Source

pub const fn new(sgn: S) -> Self

Initializes a new Cell.

Source

pub fn modify<F: FnMut(&mut S)>(&self, func: F)

Modify the signal through the function.

Although this should be safe, note that it’s subject to the same pitfalls as the nightly Cell::update. Particularly, you should avoid nested calls.

Source§

impl<S: SignalMut> Cell<S>

Source

pub fn advance(&self)

Advances the signal. Note that this only requires &self.

Source

pub fn next(&self) -> S::Sample

Gets the next sample and advances the state of the signal. Note that this only requires &self.

Trait Implementations§

Source§

impl<S: Signal> AsMut<S> for Cell<S>

If we own &mut Cell<S>, it must be the only reference.

Source§

fn as_mut(&mut self) -> &mut S

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<S: Done> Done for Cell<S>

Source§

fn is_done(&self) -> bool

Returns whether the signal has stopped producing any sound altogether. If this returns true once, it must return true in all successive times, unless retriggered. Read more
Source§

impl<S: Signal> Signal for Cell<S>

Source§

type Sample = <S as Signal>::Sample

The type of sample generated by the signal.
Source§

fn get(&self) -> Self::Sample

Gets the next sample from the signal. Read more
Source§

fn _get(&self) -> Self::Sample

Currently, rust-analyzer trips up sometimes that get is called, confusing it with Array::get. This hack bypasses this.

Auto Trait Implementations§

§

impl<S> !Freeze for Cell<S>

§

impl<S> !RefUnwindSafe for Cell<S>

§

impl<S> Send for Cell<S>
where S: Send,

§

impl<S> !Sync for Cell<S>

§

impl<S> Unpin for Cell<S>
where S: Unpin,

§

impl<S> UnwindSafe for Cell<S>
where S: UnwindSafe,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V