pub struct Selector<S, I, O> { /* private fields */ }Expand description
Equality-deduplicated derived observable.
Clones share one upstream subscription and one cached value: however many
widgets observe a selector, select runs once per source change, and
get reuses the last result while the source’s
value_version is unchanged. The upstream
subscription is released when the last downstream subscription drops.
The source is read by reference through Observable::read, so selecting
a small field from a large Signal does not clone the whole value. The
select closure runs while the source is locked and must not write to it.
Implementations§
Trait Implementations§
Source§impl<S, I, O> Observable<O> for Selector<S, I, O>
impl<S, I, O> Observable<O> for Selector<S, I, O>
fn source_id(&self) -> SourceId
fn source_name(&self) -> Arc<str> ⓘ
fn get(&self) -> O
Source§fn value_version(&self) -> Option<u64>
fn value_version(&self) -> Option<u64>
A counter identifying the current value, or
None if unknown. Read morefn subscribe(&self, observer: Observer) -> Subscription
Auto Trait Implementations§
impl<S, I, O> !RefUnwindSafe for Selector<S, I, O>
impl<S, I, O> !UnwindSafe for Selector<S, I, O>
impl<S, I, O> Forget for Selector<S, I, O>
impl<S, I, O> Freeze for Selector<S, I, O>
impl<S, I, O> Move for Selector<S, I, O>
impl<S, I, O> Send for Selector<S, I, O>
impl<S, I, O> Sync for Selector<S, I, O>
impl<S, I, O> Unpin for Selector<S, I, O>
impl<S, I, O> UnsafeUnpin for Selector<S, I, O>where
Arc<SelectorInner<S, I, O>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn 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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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.Source§fn as_any(&self) -> &(dyn Any + 'static)
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.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.