Trait dioxus_signals::Writable
source · pub trait Writable: Readable {
type Mut<'a, R: ?Sized + 'static>: DerefMut<Target = R>;
Show 13 methods
// Required methods
fn map_mut<I: ?Sized, U: ?Sized, F: FnOnce(&mut I) -> &mut U>(
ref_: Self::Mut<'_, I>,
f: F
) -> Self::Mut<'_, U>;
fn try_map_mut<I: ?Sized, U: ?Sized, F: FnOnce(&mut I) -> Option<&mut U>>(
ref_: Self::Mut<'_, I>,
f: F
) -> Option<Self::Mut<'_, U>>;
fn downcast_lifetime_mut<'a: 'b, 'b, T: ?Sized + 'static>(
mut_: Self::Mut<'a, T>
) -> Self::Mut<'b, T>;
fn try_write_unchecked(
&self
) -> Result<WritableRef<'static, Self>, BorrowMutError>;
// Provided methods
fn write(&mut self) -> WritableRef<'_, Self> { ... }
fn try_write(&mut self) -> Result<WritableRef<'_, Self>, BorrowMutError> { ... }
fn write_unchecked(&self) -> WritableRef<'static, Self> { ... }
fn with_mut<O>(&mut self, f: impl FnOnce(&mut Self::Target) -> O) -> O { ... }
fn set(&mut self, value: Self::Target)
where Self::Target: Sized { ... }
fn toggle(&mut self)
where Self::Target: Not<Output = Self::Target> + Clone { ... }
fn index_mut<I>(
&mut self,
index: I
) -> WritableRef<'_, Self, <Self::Target as Index<I>>::Output>
where Self::Target: IndexMut<I> { ... }
fn take(&mut self) -> Self::Target
where Self::Target: Default { ... }
fn replace(&mut self, value: Self::Target) -> Self::Target
where Self::Target: Sized { ... }
}Expand description
A trait for states that can be read from like crate::Signal, or crate::GlobalSignal. You may choose to accept this trait as a parameter instead of the concrete type to allow for more flexibility in your API. For example, instead of creating two functions, one that accepts a crate::Signal and one that accepts a crate::GlobalSignal, you can create one function that accepts a Writable type.
Required Associated Types§
Required Methods§
sourcefn map_mut<I: ?Sized, U: ?Sized, F: FnOnce(&mut I) -> &mut U>(
ref_: Self::Mut<'_, I>,
f: F
) -> Self::Mut<'_, U>
fn map_mut<I: ?Sized, U: ?Sized, F: FnOnce(&mut I) -> &mut U>( ref_: Self::Mut<'_, I>, f: F ) -> Self::Mut<'_, U>
Map the reference to a new type.
sourcefn try_map_mut<I: ?Sized, U: ?Sized, F: FnOnce(&mut I) -> Option<&mut U>>(
ref_: Self::Mut<'_, I>,
f: F
) -> Option<Self::Mut<'_, U>>
fn try_map_mut<I: ?Sized, U: ?Sized, F: FnOnce(&mut I) -> Option<&mut U>>( ref_: Self::Mut<'_, I>, f: F ) -> Option<Self::Mut<'_, U>>
Try to map the reference to a new type.
sourcefn downcast_lifetime_mut<'a: 'b, 'b, T: ?Sized + 'static>(
mut_: Self::Mut<'a, T>
) -> Self::Mut<'b, T>
fn downcast_lifetime_mut<'a: 'b, 'b, T: ?Sized + 'static>( mut_: Self::Mut<'a, T> ) -> Self::Mut<'b, T>
Downcast a mutable reference in a RefMut to a more specific lifetime
This function enforces the variance of the lifetime parameter 'a in Ref.
sourcefn try_write_unchecked(
&self
) -> Result<WritableRef<'static, Self>, BorrowMutError>
fn try_write_unchecked( &self ) -> Result<WritableRef<'static, Self>, BorrowMutError>
Try to get a mutable reference to the value without checking the lifetime. This will update any subscribers.
NOTE: This method is completely safe because borrow checking is done at runtime.
Provided Methods§
sourcefn write(&mut self) -> WritableRef<'_, Self>
fn write(&mut self) -> WritableRef<'_, Self>
Get a mutable reference to the value. If the value has been dropped, this will panic.
sourcefn try_write(&mut self) -> Result<WritableRef<'_, Self>, BorrowMutError>
fn try_write(&mut self) -> Result<WritableRef<'_, Self>, BorrowMutError>
Try to get a mutable reference to the value.
sourcefn write_unchecked(&self) -> WritableRef<'static, Self>
fn write_unchecked(&self) -> WritableRef<'static, Self>
Get a mutable reference to the value without checking the lifetime. This will update any subscribers.
NOTE: This method is completely safe because borrow checking is done at runtime.
sourcefn with_mut<O>(&mut self, f: impl FnOnce(&mut Self::Target) -> O) -> O
fn with_mut<O>(&mut self, f: impl FnOnce(&mut Self::Target) -> O) -> O
Run a function with a mutable reference to the value. If the value has been dropped, this will panic.
sourcefn set(&mut self, value: Self::Target)
fn set(&mut self, value: Self::Target)
Set the value of the signal. This will trigger an update on all subscribers.
sourcefn toggle(&mut self)
fn toggle(&mut self)
Invert the boolean value of the signal. This will trigger an update on all subscribers.
sourcefn index_mut<I>(
&mut self,
index: I
) -> WritableRef<'_, Self, <Self::Target as Index<I>>::Output>
fn index_mut<I>( &mut self, index: I ) -> WritableRef<'_, Self, <Self::Target as Index<I>>::Output>
Index into the inner value and return a reference to the result.