summaryrefslogtreecommitdiffstats
path: root/futures/src/subscription/tracker.rs
diff options
context:
space:
mode:
Diffstat (limited to 'futures/src/subscription/tracker.rs')
-rw-r--r--futures/src/subscription/tracker.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/futures/src/subscription/tracker.rs b/futures/src/subscription/tracker.rs
index cfa36170..43222b5b 100644
--- a/futures/src/subscription/tracker.rs
+++ b/futures/src/subscription/tracker.rs
@@ -1,6 +1,6 @@
-use crate::Subscription;
+use crate::{BoxFuture, Subscription};
-use futures::{channel::mpsc, future::BoxFuture, sink::Sink};
+use futures::{channel::mpsc, sink::Sink};
use std::{collections::HashMap, marker::PhantomData};
/// A registry of subscription streams.
@@ -26,8 +26,6 @@ where
Event: 'static + Send + Clone,
{
/// Creates a new empty [`Tracker`].
- ///
- /// [`Tracker`]: struct.Tracker.html
pub fn new() -> Self {
Self {
subscriptions: HashMap::new(),
@@ -52,14 +50,12 @@ where
/// It returns a list of futures that need to be spawned to materialize
/// the [`Tracker`] changes.
///
- /// [`Tracker`]: struct.Tracker.html
- /// [`Subscription`]: struct.Subscription.html
- /// [`Recipe`]: trait.Recipe.html
+ /// [`Recipe`]: crate::subscription::Recipe
pub fn update<Message, Receiver>(
&mut self,
subscription: Subscription<Hasher, Event, Message>,
receiver: Receiver,
- ) -> Vec<BoxFuture<'static, ()>>
+ ) -> Vec<BoxFuture<()>>
where
Message: 'static + Send,
Receiver: 'static
@@ -70,7 +66,7 @@ where
{
use futures::{future::FutureExt, stream::StreamExt};
- let mut futures = Vec::new();
+ let mut futures: Vec<BoxFuture<()>> = Vec::new();
let recipes = subscription.recipes();
let mut alive = std::collections::HashSet::new();
@@ -115,7 +111,7 @@ where
},
);
- futures.push(future.boxed());
+ futures.push(Box::pin(future));
}
self.subscriptions.retain(|id, _| alive.contains(&id));
@@ -131,6 +127,8 @@ where
///
/// This method publishes the given event to all the subscription streams
/// currently open.
+ ///
+ /// [`Recipe::stream`]: crate::subscription::Recipe::stream
pub fn broadcast(&mut self, event: Event) {
self.subscriptions
.values_mut()