pub struct Source<T> { /* private fields */ }Expand description
A watchable event channel with no current value.
Subscribers receive Signal::Value when emit is called
and Signal::Complete when complete is called.
There is no get() and no last-value storage — this is the entire point of
Source vs. Cell.
Implementations§
Source§impl<T: CellValue> Source<T>
impl<T: CellValue> Source<T>
Sourcepub fn downgrade(&self) -> WeakSource<T>
pub fn downgrade(&self) -> WeakSource<T>
Create a weak reference to this source.
Sourcepub fn own(&self, guard: SubscriptionGuard)
pub fn own(&self, guard: SubscriptionGuard)
Take ownership of a subscription guard, dropping it when this source is dropped.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Returns true if this source has completed.
Sourcepub fn with_name(self, _name: impl Into<Arc<str>>) -> Self
pub fn with_name(self, _name: impl Into<Arc<str>>) -> Self
Builder-style name attachment, kept for API compatibility with
Cell::with_name. Source carries no name
field, so this is a no-op.
Sourcepub fn subscribe(
&self,
callback: impl Fn(&Signal<T>) + Send + Sync + 'static,
) -> SubscriptionGuard
pub fn subscribe( &self, callback: impl Fn(&Signal<T>) + Send + Sync + 'static, ) -> SubscriptionGuard
Subscribe to all signals. Returns a guard that unsubscribes when dropped.
Unlike Cell::subscribe, Source::subscribe does not
invoke the callback synchronously with a current value — there is no
current value. The callback fires only on subsequent emit
or complete calls.
Sourcepub fn emit(&self, value: T)
pub fn emit(&self, value: T)
Emit a value to all subscribers. Does not store the value — there
is no .get() on Source.
This is the hot path. Compared to Cell::set it
skips the value: ArcSwap<T> store and the associated Debt::pay_all
drop on the previous value. Useful when emission rate is high
(timers, clocks, ticks).
Trait Implementations§
Source§impl<T: Send + Sync> DepNode for Source<T>
impl<T: Send + Sync> DepNode for Source<T>
fn id(&self) -> Uuid
fn name(&self) -> Option<String>
Source§fn subscriber_count(&self) -> usize
fn subscriber_count(&self) -> usize
Source§fn owned_count(&self) -> usize
fn owned_count(&self) -> usize
fn display_name(&self) -> String
fn dependency_count(&self) -> usize
fn has_dependencies(&self) -> bool
fn dependency_tree(&self) -> Stringwhere
Self: Sized,
fn print_dependency_tree(&self)where
Self: Sized,
impl<T: CellValue> Pipeline<T, Empty> for Source<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Source<T>
impl<T> !UnwindSafe for Source<T>
impl<T> Freeze for Source<T>
impl<T> Send for Source<T>
impl<T> Sync for Source<T>
impl<T> Unpin for Source<T>where
T: Unpin,
impl<T> UnsafeUnpin for Source<T>
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
Source§impl<T, E, S, P> CatchErrorExt<T, E, S> for P
impl<T, E, S, P> CatchErrorExt<T, E, S> for P
fn catch_error<F>(self, f: F) -> impl Materialize<T, S>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S, P> DedupedExt<T, S> for P
impl<T, S, P> DedupedExt<T, S> for P
fn deduped(self) -> impl Materialize<T, S>where
T: PartialEq,
Source§impl<T, P> DistinctExt<T, Empty> for P
impl<T, P> DistinctExt<T, Empty> for P
Source§impl<T, P> DistinctUntilChangedByExt<T, Empty> for P
impl<T, P> DistinctUntilChangedByExt<T, Empty> for P
Source§impl<T, P> FinalizeExt<T, Empty> for P
impl<T, P> FinalizeExt<T, Empty> for P
Source§impl<T, S, P> FirstExt<T, S> for P
impl<T, S, P> FirstExt<T, S> for P
Source§fn first(self) -> impl Materialize<T, S>
fn first(self) -> impl Materialize<T, S>
take(1).Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> JoinKeyFrom<T> for Twhere
T: Clone,
impl<T> JoinKeyFrom<T> for Twhere
T: Clone,
fn join_key_from(value: &T) -> T
Source§impl<P, T, S> Materialize<T, S> for P
impl<P, T, S> Materialize<T, S> for P
fn materialize(self) -> Cell<<S as Seedness>::Materialized<T>, CellImmutable>
Source§impl<T, S, P> PairwiseExt<T, S> for P
impl<T, S, P> PairwiseExt<T, S> for P
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, S, P> SkipWhileExt<T, S> for P
impl<T, S, P> SkipWhileExt<T, S> for P
Source§impl<T, S, P> TakeWhileExt<T, S> for P
impl<T, S, P> TakeWhileExt<T, S> for P
Source§fn take_while<F>(self, predicate: F) -> impl Materialize<T, Empty>
fn take_while<F>(self, predicate: F) -> impl Materialize<T, Empty>
true. On the first false,
emit Complete and ignore all subsequent values.