Skip to main content

Source

Struct Source 

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

Source

pub fn new() -> Self

Create a new source with no subscribers.

Source

pub fn downgrade(&self) -> WeakSource<T>

Create a weak reference to this source.

Source

pub fn own(&self, guard: SubscriptionGuard)

Take ownership of a subscription guard, dropping it when this source is dropped.

Source

pub fn is_complete(&self) -> bool

Returns true if this source has completed.

Source

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.

Source

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.

Source

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).

Source

pub fn complete(&self)

Mark this source as completed. Subsequent emit calls are dropped silently.

Trait Implementations§

Source§

impl<T> Clone for Source<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: CellValue> Default for Source<T>

Source§

fn default() -> Self

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

impl<T: Send + Sync> DepNode for Source<T>

Source§

fn id(&self) -> Uuid

Source§

fn name(&self) -> Option<String>

Source§

fn deps(&self) -> Vec<Arc<dyn DepNode>>

Returns the dependencies of this node.
Source§

fn subscriber_count(&self) -> usize

Returns the number of active subscribers to this node.
Source§

fn owned_count(&self) -> usize

Returns the number of subscription guards owned by this node.
Source§

fn display_name(&self) -> String

Source§

fn dependency_count(&self) -> usize

Source§

fn has_dependencies(&self) -> bool

Source§

fn dependency_tree(&self) -> String
where Self: Sized,

Source§

fn print_dependency_tree(&self)
where Self: Sized,

Source§

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>
where T: Send + Sync,

§

impl<T> Sync for Source<T>
where T: Sync + Send,

§

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

§

impl<T> UnsafeUnpin for Source<T>

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, E, S, P> CatchErrorExt<T, E, S> for P
where T: CellValue, E: CellValue, S: Seedness, P: Pipeline<Result<T, E>, S> + MapExt<Result<T, E>, S>,

Source§

fn catch_error<F>(self, f: F) -> impl Materialize<T, S>
where Self: Sized, F: Fn(&E) -> T + Send + Sync + 'static,

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

impl<T, S, P> ColdExt<T, S> for P
where T: CellValue, S: Seedness, P: Pipeline<T, S>,

Source§

fn cold(self) -> impl Materialize<Arc<T>, Empty>

Drop the synchronous-on-subscribe initial emission; subsequent values flow through wrapped in Arc for cheap forwarding. Read more
Source§

impl<T, S, P> DedupedExt<T, S> for P
where T: CellValue, S: Seedness, P: Pipeline<T, S> + DistinctUntilChangedByExt<T, S>,

Source§

fn deduped(self) -> impl Materialize<T, S>
where T: PartialEq,

Source§

impl<T, P> DistinctExt<T, Empty> for P
where T: CellValue + Eq + Hash, P: Pipeline<T, Empty>,

Source§

fn distinct(self) -> impl Materialize<T, Empty>

Filter out values that have already been emitted (by Hash/Eq). Read more
Source§

impl<T, P> DistinctUntilChangedByExt<T, Empty> for P
where T: CellValue, P: Pipeline<T, Empty>,

Source§

fn distinct_until_changed_by<F>( self, comparator: F, ) -> impl Materialize<T, Empty>
where F: Fn(&T, &T) -> bool + Send + Sync + 'static,

Like deduped() but with a custom comparator. Read more
Source§

impl<T, S, P> FilterExt<T, S> for P
where T: CellValue, S: Seedness, P: Pipeline<T, S>,

Source§

fn filter<P>(self, predicate: P) -> impl Materialize<T, Empty>
where P: Fn(&T) -> bool + Send + Sync + 'static,

Source§

impl<T, P> FinalizeExt<T, Empty> for P
where T: CellValue, P: Pipeline<T, Empty>,

Source§

fn finalize<F>(self, callback: F) -> impl Materialize<T, Empty>
where F: FnOnce() + Send + Sync + 'static,

Execute a callback exactly once when the stream completes or errors. Read more
Source§

impl<T, S, P> FirstExt<T, S> for P
where T: CellValue, S: Seedness, P: Pipeline<T, S> + TakeExt<T, S>,

Source§

fn first(self) -> impl Materialize<T, S>

Take only the first value, then complete. Equivalent to take(1).
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

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

Source§

fn join_key_from(value: &T) -> T

Source§

impl<T, S, P> LastExt<T, S> for P
where T: CellValue, S: Seedness, P: Pipeline<T, S>,

Source§

fn last(self) -> impl Materialize<T, Empty>

Emit only the most recent value when the source completes. Read more
Source§

fn last_or(self, default: T) -> impl Materialize<T, Empty>

Emit only the most recent value, or default if the source completes without emitting any values. Read more
Source§

impl<T, E, S, P> MapErrExt<T, E, S> for P
where T: CellValue, E: CellValue, S: Seedness, P: Pipeline<Result<T, E>, S> + MapExt<Result<T, E>, S>,

Source§

fn map_err<E2, F>(self, f: F) -> impl Materialize<Result<T, E2>, S>
where Self: Sized, E2: CellValue, F: Fn(&E) -> E2 + Send + Sync + 'static,

Source§

impl<T, P> MapExt<T, Empty> for P
where T: CellValue, P: Pipeline<T, Empty>,

Source§

fn map<U, F>(self, f: F) -> impl Materialize<U, Empty>
where U: CellValue, F: Fn(&T) -> U + Send + Sync + 'static,

Source§

impl<T, E, S, P> MapOkExt<T, E, S> for P
where T: CellValue, E: CellValue, S: Seedness, P: Pipeline<Result<T, E>, S> + MapExt<Result<T, E>, S>,

Source§

fn map_ok<U, F>(self, f: F) -> impl Materialize<Result<U, E>, S>
where Self: Sized, U: CellValue, F: Fn(&T) -> U + Send + Sync + 'static,

Source§

impl<P, T, S> Materialize<T, S> for P
where P: Pipeline<T, S>, T: CellValue, S: Seedness,

Source§

fn materialize(self) -> Cell<<S as Seedness>::Materialized<T>, CellImmutable>

Source§

impl<T, S, P> PairwiseExt<T, S> for P
where T: CellValue, S: Seedness, P: Pipeline<T, S>,

Source§

fn pairwise(self) -> impl Materialize<(T, T), Empty>

Emit (prev, current) pairs for each consecutive pair of values.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, P> ScanExt<T, Empty> for P
where T: CellValue, P: Pipeline<T, Empty>,

Source§

fn scan<U, F>(self, initial: U, f: F) -> impl Materialize<U, Empty>
where U: CellValue, F: Fn(&U, &T) -> U + Send + Sync + 'static,

Source§

impl<T, S, P> SkipExt<T, S> for P
where T: CellValue, S: Seedness, P: Pipeline<T, S>,

Source§

fn skip(self, count: usize) -> impl Materialize<T, Empty>

Source§

impl<T, S, P> SkipWhileExt<T, S> for P
where T: CellValue, S: Seedness, P: Pipeline<T, S>,

Source§

fn skip_while<F>(self, predicate: F) -> impl Materialize<T, Empty>
where F: Fn(&T) -> bool + Send + Sync + 'static,

Skip emissions while the predicate returns true. Read more
Source§

impl<T, P> TakeExt<T, Empty> for P
where T: CellValue, P: Pipeline<T, Empty>,

Source§

fn take(self, count: usize) -> impl Materialize<T, Empty>

Source§

impl<T, S, P> TakeWhileExt<T, S> for P
where T: CellValue, S: Seedness, P: Pipeline<T, S>,

Source§

fn take_while<F>(self, predicate: F) -> impl Materialize<T, Empty>
where F: Fn(&T) -> bool + Send + Sync + 'static,

Forward values while the predicate returns true. On the first false, emit Complete and ignore all subsequent values.
Source§

impl<T, P> TapExt<T, Empty> for P
where T: CellValue, P: Pipeline<T, Empty>,

Source§

fn tap<F>(self, f: F) -> impl Materialize<T, Empty>
where F: Fn(&T) + Send + Sync + 'static,

Run f(&value) for side effects and forward the value untransformed. Read more
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
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<T, P> TryMapExt<T, Empty> for P
where T: CellValue, P: Pipeline<T, Empty>,

Source§

fn try_map<U, E, F>(self, f: F) -> impl Materialize<Result<U, E>, Empty>
where U: CellValue, E: CellValue, F: Fn(&T) -> Result<U, E> + Send + Sync + 'static,

Transform values with a fallible function. Read more
Source§

impl<T, E, S, P> UnwrapOrExt<T, E, S> for P
where T: CellValue, E: CellValue, S: Seedness, P: Pipeline<Result<T, E>, S> + MapExt<Result<T, E>, S> + CatchErrorExt<T, E, S>,

Source§

fn unwrap_or(self, default: T) -> impl Materialize<T, S>
where Self: Sized,

Source§

fn unwrap_or_else<F>(self, f: F) -> impl Materialize<T, S>
where Self: Sized, F: Fn(&E) -> T + Send + Sync + 'static,