Signal

Struct Signal 

pub struct Signal<T> { /* private fields */ }
Expand description

A local (UI-thread) read write Signal.

Implementations§

§

impl<T> Signal<T>

pub fn id(&self) -> Id

pub fn read_only(&self) -> ReadSignal<T>

Create a Getter of this Signal

pub fn write_only(&self) -> WriteSignal<T>

Create a Setter of this Signal

§

impl<T> Signal<T>
where T: 'static,

pub fn new(value: T) -> Signal<T>

pub fn new_split(value: T) -> (ReadSignal<T>, WriteSignal<T>)

Trait Implementations§

§

impl<T> Add<T> for Signal<T>
where T: 'static + Add<Output = T>, &'a T: for<'a> Add<T, Output = T>,

§

type Output = T

The resulting type after applying the + operator.
§

fn add(self, rhs: T) -> <Signal<T> as Add<T>>::Output

Performs the + operation. Read more
§

impl<T> AddAssign<T> for Signal<T>
where T: AddAssign + 'static,

§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
§

impl<T> BitAnd<T> for Signal<T>
where T: 'static + BitAnd<Output = T>, &'a T: for<'a> BitAnd<T, Output = T>,

§

type Output = T

The resulting type after applying the & operator.
§

fn bitand(self, rhs: T) -> <Signal<T> as BitAnd<T>>::Output

Performs the & operation. Read more
§

impl<T> BitAndAssign<T> for Signal<T>
where T: BitAndAssign + 'static,

§

fn bitand_assign(&mut self, rhs: T)

Performs the &= operation. Read more
§

impl<T> BitOr<T> for Signal<T>
where T: 'static + BitOr<Output = T>, &'a T: for<'a> BitOr<T, Output = T>,

§

type Output = T

The resulting type after applying the | operator.
§

fn bitor(self, rhs: T) -> <Signal<T> as BitOr<T>>::Output

Performs the | operation. Read more
§

impl<T> BitOrAssign<T> for Signal<T>
where T: BitOrAssign + 'static,

§

fn bitor_assign(&mut self, rhs: T)

Performs the |= operation. Read more
§

impl<T> BitXor<T> for Signal<T>
where T: 'static + BitXor<Output = T>, &'a T: for<'a> BitXor<T, Output = T>,

§

type Output = T

The resulting type after applying the ^ operator.
§

fn bitxor(self, rhs: T) -> <Signal<T> as BitXor<T>>::Output

Performs the ^ operation. Read more
§

impl<T> BitXorAssign<T> for Signal<T>
where T: BitXorAssign + 'static,

§

fn bitxor_assign(&mut self, rhs: T)

Performs the ^= operation. Read more
§

impl<T> Clone for Signal<T>

§

fn clone(&self) -> Signal<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Debug for Signal<T>

§

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

Formats the value using the given formatter. Read more
§

impl<T> Default for Signal<T>
where T: Default + 'static,

§

fn default() -> Signal<T>

Returns the “default value” for a type. Read more
§

impl<T> Display for Signal<T>
where T: Display + 'static,

§

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

Formats the value using the given formatter. Read more
§

impl<T> Div<T> for Signal<T>
where T: 'static + Div<Output = T>, &'a T: for<'a> Div<T, Output = T>,

§

type Output = T

The resulting type after applying the / operator.
§

fn div(self, rhs: T) -> <Signal<T> as Div<T>>::Output

Performs the / operation. Read more
§

impl<T> DivAssign<T> for Signal<T>
where T: DivAssign + 'static,

§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
§

impl<T> From<T> for Signal<T>
where T: 'static,

§

fn from(value: T) -> Signal<T>

Converts to this type from the input type.
§

impl<T> Mul<T> for Signal<T>
where T: 'static + Mul<Output = T>, &'a T: for<'a> Mul<T, Output = T>,

§

type Output = T

The resulting type after applying the * operator.
§

fn mul(self, rhs: T) -> <Signal<T> as Mul<T>>::Output

Performs the * operation. Read more
§

impl<T> MulAssign<T> for Signal<T>
where T: MulAssign + 'static,

§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
§

impl<T> Neg for Signal<T>
where T: 'static, &'a T: for<'a> Neg<Output = T>,

§

type Output = T

The resulting type after applying the - operator.
§

fn neg(self) -> <Signal<T> as Neg>::Output

Performs the unary - operation. Read more
§

impl<T> Not for Signal<T>
where T: 'static, &'a T: for<'a> Not<Output = T>,

§

type Output = T

The resulting type after applying the ! operator.
§

fn not(self) -> <Signal<T> as Not>::Output

Performs the unary ! operation. Read more
§

impl<T> PartialEq<T> for Signal<T>
where T: PartialEq + 'static,

§

fn eq(&self, other: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T> PartialEq for Signal<T>

§

fn eq(&self, other: &Signal<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T> Rem<T> for Signal<T>
where T: 'static + Rem<Output = T>, &'a T: for<'a> Rem<T, Output = T>,

§

type Output = T

The resulting type after applying the % operator.
§

fn rem(self, rhs: T) -> <Signal<T> as Rem<T>>::Output

Performs the % operation. Read more
§

impl<T> RemAssign<T> for Signal<T>
where T: RemAssign + 'static,

§

fn rem_assign(&mut self, rhs: T)

Performs the %= operation. Read more
Source§

impl<T> Res<T> for Signal<T>
where T: Clone + 'static,

Source§

fn get_value(&self, _: &impl DataContext) -> T

Returns the value of a resource by value.
Source§

fn set_or_bind<F>(self, cx: &mut Context, closure: F)
where F: 'static + Fn(&mut Context, Signal<T>),

Source§

fn to_signal(self, _cx: &mut Context) -> Signal<T>
where Signal<T>: Sized + 'static, T: Clone + 'static,

Converts this signal into a signal mirror tied to entity. Read more
§

impl<T> Shl<T> for Signal<T>
where T: 'static + Shl<Output = T>, &'a T: for<'a> Shl<T, Output = T>,

§

type Output = T

The resulting type after applying the << operator.
§

fn shl(self, rhs: T) -> <Signal<T> as Shl<T>>::Output

Performs the << operation. Read more
§

impl<T> ShlAssign<T> for Signal<T>
where T: ShlAssign + 'static,

§

fn shl_assign(&mut self, rhs: T)

Performs the <<= operation. Read more
§

impl<T> Shr<T> for Signal<T>
where T: 'static + Shr<Output = T>, &'a T: for<'a> Shr<T, Output = T>,

§

type Output = T

The resulting type after applying the >> operator.
§

fn shr(self, rhs: T) -> <Signal<T> as Shr<T>>::Output

Performs the >> operation. Read more
§

impl<T> ShrAssign<T> for Signal<T>
where T: ShrAssign + 'static,

§

fn shr_assign(&mut self, rhs: T)

Performs the >>= operation. Read more
§

impl<T> SignalGet<T> for Signal<T>
where T: Clone,

§

fn id(&self) -> Id

get the Signal Id
§

fn get_untracked(&self) -> T
where T: 'static,

§

fn get(&self) -> T
where T: 'static,

§

fn try_get(&self) -> Option<T>
where T: 'static,

§

fn try_get_untracked(&self) -> Option<T>
where T: 'static,

§

impl<T> SignalRead<T> for Signal<T>

§

fn id(&self) -> Id

get the Signal Id
§

fn try_read(&self) -> Option<ReadRef<'_, T>>
where T: 'static,

If the signal isn’t disposed, reads the data stored in the Signal and subscribes to the current running effect.
§

fn try_read_untracked(&self) -> Option<ReadRef<'_, T>>
where T: 'static,

If the signal isn’t disposed, reads the data stored in the Signal without subscribing.
§

fn read(&self) -> ReadRef<'_, T>
where T: 'static,

Reads the data stored in the Signal, subscribing the current running effect.
§

fn read_untracked(&self) -> ReadRef<'_, T>
where T: 'static,

Reads the data stored in the Signal without subscribing.
§

impl<T> SignalTrack<T> for Signal<T>

§

fn id(&self) -> Id

§

fn track(&self)

Only subscribes to the current running effect to this Signal.
§

fn try_track(&self)

If the signal isn’t disposed,
§

impl<T> SignalUpdate<T> for Signal<T>

§

fn id(&self) -> Id

get the Signal Id
§

fn set(&self, new_value: T)
where T: 'static,

Sets the new_value to the Signal and triggers effect run
§

fn update(&self, f: impl FnOnce(&mut T))
where T: 'static,

Update the stored value with the given function and triggers effect run
§

fn try_update<O>(&self, f: impl FnOnce(&mut T) -> O) -> Option<O>
where T: 'static,

Update the stored value with the given function, triggers effect run, and returns the value returned by the function
§

fn set_if_changed(&self, new_value: T)
where T: PartialEq + 'static,

Sets the new_value to the Signal and triggers effect run only if the value has changed
§

impl<T> SignalWith<T> for Signal<T>

§

fn id(&self) -> Id

get the Signal Id
§

fn with<O>(&self, f: impl FnOnce(&T) -> O) -> O
where T: 'static,

§

fn with_untracked<O>(&self, f: impl FnOnce(&T) -> O) -> O
where T: 'static,

§

fn try_with<O>(&self, f: impl FnOnce(Option<&T>) -> O) -> O
where T: 'static,

§

fn try_with_untracked<O>(&self, f: impl FnOnce(Option<&T>) -> O) -> O
where T: 'static,

§

impl<T> SignalWrite<T> for Signal<T>

§

fn id(&self) -> Id

get the Signal Id
§

fn write(&self) -> WriteRef<'_, T>
where T: 'static,

Mutably borrows the signal value, triggering subscribers when dropped.
§

fn try_write(&self) -> Option<WriteRef<'_, T>>
where T: 'static,

If the Signal isn’t disposed, mutably borrows the signal value.
§

impl<T> Sub<T> for Signal<T>
where T: 'static + Sub<Output = T>, &'a T: for<'a> Sub<T, Output = T>,

§

type Output = T

The resulting type after applying the - operator.
§

fn sub(self, rhs: T) -> <Signal<T> as Sub<T>>::Output

Performs the - operation. Read more
§

impl<T> SubAssign<T> for Signal<T>
where T: SubAssign + 'static,

§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
§

impl<T> Copy for Signal<T>

§

impl<T> Eq for Signal<T>

Auto Trait Implementations§

§

impl<T> Freeze for Signal<T>

§

impl<T> RefUnwindSafe for Signal<T>
where T: RefUnwindSafe,

§

impl<T> Send for Signal<T>
where T: Send,

§

impl<T> Sync for Signal<T>
where T: Sync,

§

impl<T> Unpin for Signal<T>
where T: Unpin,

§

impl<T> UnwindSafe for Signal<T>
where T: 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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T, S> SignalMap<T> for S
where T: 'static, S: SignalWith<T> + Copy + 'static,

§

fn map<U, F>(self, map: F) -> Memo<U>
where U: Clone + PartialEq + 'static, F: 'static + Fn(&T) -> U,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringLocalized for T
where T: ToString,

Source§

fn to_string_local(&self, _cx: &impl DataContext) -> String

Method for converting the current type to a String via a translation using fluent.
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,