pub struct Tracker<Hasher, Event> { /* private fields */ }
Expand description

A registry of subscription streams.

If you have an application that continuously returns a Subscription, you can use a Tracker to keep track of the different recipes and keep its executions alive.

Implementations§

source§

impl<Hasher, Event> Tracker<Hasher, Event>where Hasher: Hasher + Default, Event: 'static + Send + Clone,

source

pub fn new() -> Self

Creates a new empty Tracker.

source

pub fn update<Message, Receiver>( &mut self, subscription: Subscription<Hasher, Event, Message>, receiver: Receiver ) -> Vec<BoxFuture<()>>where Message: 'static + MaybeSend, Receiver: 'static + Sink<Message, Error = SendError> + Unpin + MaybeSend + Clone,

Updates the Tracker with the given Subscription.

A Subscription can cause new streams to be spawned or old streams to be closed.

The Tracker keeps track of these streams between calls to this method:

  • If the provided Subscription contains a new Recipe that is currently not being run, it will spawn a new stream and keep it alive.
  • On the other hand, if a Recipe is currently in execution and the provided Subscription does not contain it anymore, then the Tracker will close and drop the relevant stream.

It returns a list of futures that need to be spawned to materialize the Tracker changes.

source

pub fn broadcast(&mut self, event: Event)

Broadcasts an event to the subscriptions currently alive.

A subscription’s Recipe::stream always receives a stream of events as input. This stream can be used by some subscription to listen to shell events.

This method publishes the given event to all the subscription streams currently open.

Trait Implementations§

source§

impl<Hasher: Debug, Event: Debug> Debug for Tracker<Hasher, Event>

source§

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

Formats the value using the given formatter. Read more
source§

impl<Hasher, Event> Default for Tracker<Hasher, Event>where Hasher: Hasher + Default, Event: 'static + Send + Clone,

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<Hasher, Event> !RefUnwindSafe for Tracker<Hasher, Event>

§

impl<Hasher, Event> Send for Tracker<Hasher, Event>where Event: Send, Hasher: Send,

§

impl<Hasher, Event> Sync for Tracker<Hasher, Event>where Event: Send, Hasher: Sync,

§

impl<Hasher, Event> Unpin for Tracker<Hasher, Event>where Hasher: Unpin,

§

impl<Hasher, Event> !UnwindSafe for Tracker<Hasher, Event>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.