Use recently stabilized intra-doc links
See RFC: https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md
This commit is contained in:
parent
d612bf5678
commit
01322f69a4
135 changed files with 135 additions and 1769 deletions
|
|
@ -5,9 +5,6 @@ use futures::future::{Future, FutureExt};
|
|||
///
|
||||
/// You should be able to turn a future easily into a [`Command`], either by
|
||||
/// using the `From` trait or [`Command::perform`].
|
||||
///
|
||||
/// [`Command`]: struct.Command.html
|
||||
/// [`Command::perform`]: #method.perform
|
||||
pub struct Command<T> {
|
||||
futures: Vec<BoxFuture<T>>,
|
||||
}
|
||||
|
|
@ -16,8 +13,6 @@ impl<T> Command<T> {
|
|||
/// Creates an empty [`Command`].
|
||||
///
|
||||
/// In other words, a [`Command`] that does nothing.
|
||||
///
|
||||
/// [`Command`]: struct.Command.html
|
||||
pub fn none() -> Self {
|
||||
Self {
|
||||
futures: Vec::new(),
|
||||
|
|
@ -25,8 +20,6 @@ impl<T> Command<T> {
|
|||
}
|
||||
|
||||
/// Creates a [`Command`] that performs the action of the given future.
|
||||
///
|
||||
/// [`Command`]: struct.Command.html
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn perform<A>(
|
||||
future: impl Future<Output = T> + 'static + Send,
|
||||
|
|
@ -38,8 +31,6 @@ impl<T> Command<T> {
|
|||
}
|
||||
|
||||
/// Creates a [`Command`] that performs the action of the given future.
|
||||
///
|
||||
/// [`Command`]: struct.Command.html
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn perform<A>(
|
||||
future: impl Future<Output = T> + 'static,
|
||||
|
|
@ -51,8 +42,6 @@ impl<T> Command<T> {
|
|||
}
|
||||
|
||||
/// Applies a transformation to the result of a [`Command`].
|
||||
///
|
||||
/// [`Command`]: struct.Command.html
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn map<A>(
|
||||
mut self,
|
||||
|
|
@ -78,8 +67,6 @@ impl<T> Command<T> {
|
|||
}
|
||||
|
||||
/// Applies a transformation to the result of a [`Command`].
|
||||
///
|
||||
/// [`Command`]: struct.Command.html
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn map<A>(mut self, f: impl Fn(T) -> A + 'static) -> Command<A>
|
||||
where
|
||||
|
|
@ -105,8 +92,6 @@ impl<T> Command<T> {
|
|||
/// commands.
|
||||
///
|
||||
/// Once this command is run, all the commands will be executed at once.
|
||||
///
|
||||
/// [`Command`]: struct.Command.html
|
||||
pub fn batch(commands: impl IntoIterator<Item = Command<T>>) -> Self {
|
||||
Self {
|
||||
futures: commands
|
||||
|
|
@ -117,8 +102,6 @@ impl<T> Command<T> {
|
|||
}
|
||||
|
||||
/// Converts a [`Command`] into its underlying list of futures.
|
||||
///
|
||||
/// [`Command`]: struct.Command.html
|
||||
pub fn futures(self) -> Vec<BoxFuture<T>> {
|
||||
self.futures
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,21 +38,15 @@ use futures::Future;
|
|||
/// A type that can run futures.
|
||||
pub trait Executor: Sized {
|
||||
/// Creates a new [`Executor`].
|
||||
///
|
||||
/// [`Executor`]: trait.Executor.html
|
||||
fn new() -> Result<Self, futures::io::Error>
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
/// Spawns a future in the [`Executor`].
|
||||
///
|
||||
/// [`Executor`]: trait.Executor.html
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn spawn(&self, future: impl Future<Output = ()> + Send + 'static);
|
||||
|
||||
/// Spawns a local future in the [`Executor`].
|
||||
///
|
||||
/// [`Executor`]: trait.Executor.html
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn spawn(&self, future: impl Future<Output = ()> + 'static);
|
||||
|
||||
|
|
@ -62,8 +56,6 @@ pub trait Executor: Sized {
|
|||
/// before creating futures. This method can be leveraged to set up this
|
||||
/// global state, call a function, restore the state, and obtain the result
|
||||
/// of the call.
|
||||
///
|
||||
/// [`Executor`]: trait.Executor.html
|
||||
fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
|
||||
f()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,6 @@ use std::marker::PhantomData;
|
|||
///
|
||||
/// If you have an [`Executor`], a [`Runtime`] can be leveraged to run any
|
||||
/// [`Command`] or [`Subscription`] and get notified of the results!
|
||||
///
|
||||
/// [`Runtime`]: struct.Runtime.html
|
||||
/// [`Executor`]: executor/trait.Executor.html
|
||||
/// [`Command`]: struct.Command.html
|
||||
/// [`Subscription`]: subscription/struct.Subscription.html
|
||||
#[derive(Debug)]
|
||||
pub struct Runtime<Hasher, Event, Executor, Sender, Message> {
|
||||
executor: Executor,
|
||||
|
|
@ -36,8 +31,6 @@ where
|
|||
/// You need to provide:
|
||||
/// - an [`Executor`] to spawn futures
|
||||
/// - a `Sender` implementing `Sink` to receive the results
|
||||
///
|
||||
/// [`Runtime`]: struct.Runtime.html
|
||||
pub fn new(executor: Executor, sender: Sender) -> Self {
|
||||
Self {
|
||||
executor,
|
||||
|
|
@ -50,10 +43,6 @@ where
|
|||
/// Runs the given closure inside the [`Executor`] of the [`Runtime`].
|
||||
///
|
||||
/// See [`Executor::enter`] to learn more.
|
||||
///
|
||||
/// [`Executor`]: executor/trait.Executor.html
|
||||
/// [`Runtime`]: struct.Runtime.html
|
||||
/// [`Executor::enter`]: executor/trait.Executor.html#method.enter
|
||||
pub fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
|
||||
self.executor.enter(f)
|
||||
}
|
||||
|
|
@ -62,9 +51,6 @@ where
|
|||
///
|
||||
/// The resulting `Message` will be forwarded to the `Sender` of the
|
||||
/// [`Runtime`].
|
||||
///
|
||||
/// [`Command`]: struct.Command.html
|
||||
/// [`Runtime`]: struct.Runtime.html
|
||||
pub fn spawn(&mut self, command: Command<Message>) {
|
||||
use futures::{FutureExt, SinkExt};
|
||||
|
||||
|
|
@ -88,9 +74,7 @@ where
|
|||
/// It will spawn new streams or close old ones as necessary! See
|
||||
/// [`Tracker::update`] to learn more about this!
|
||||
///
|
||||
/// [`Subscription`]: subscription/struct.Subscription.html
|
||||
/// [`Runtime`]: struct.Runtime.html
|
||||
/// [`Tracker::update`]: subscription/struct.Tracker.html#method.update
|
||||
/// [`Tracker::update`]: subscription::Tracker::update
|
||||
pub fn track(
|
||||
&mut self,
|
||||
subscription: Subscription<Hasher, Event, Message>,
|
||||
|
|
@ -115,9 +99,7 @@ where
|
|||
///
|
||||
/// See [`Tracker::broadcast`] to learn more.
|
||||
///
|
||||
/// [`Runtime`]: struct.Runtime.html
|
||||
/// [`Tracker::broadcast`]:
|
||||
/// subscription/struct.Tracker.html#method.broadcast
|
||||
/// [`Tracker::broadcast`]: subscription::Tracker::broadcast
|
||||
pub fn broadcast(&mut self, event: Event) {
|
||||
self.subscriptions.broadcast(event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ use crate::BoxStream;
|
|||
/// This type is normally aliased by runtimes with a specific `Event` and/or
|
||||
/// `Hasher`.
|
||||
///
|
||||
/// [`Command`]: ../struct.Command.html
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
/// [`Command`]: crate::Command
|
||||
pub struct Subscription<Hasher, Event, Output> {
|
||||
recipes: Vec<Box<dyn Recipe<Hasher, Event, Output = Output>>>,
|
||||
}
|
||||
|
|
@ -30,8 +29,6 @@ where
|
|||
H: std::hash::Hasher,
|
||||
{
|
||||
/// Returns an empty [`Subscription`] that will not produce any output.
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
pub fn none() -> Self {
|
||||
Self {
|
||||
recipes: Vec::new(),
|
||||
|
|
@ -39,9 +36,6 @@ where
|
|||
}
|
||||
|
||||
/// Creates a [`Subscription`] from a [`Recipe`] describing it.
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
/// [`Recipe`]: trait.Recipe.html
|
||||
pub fn from_recipe(
|
||||
recipe: impl Recipe<H, E, Output = O> + 'static,
|
||||
) -> Self {
|
||||
|
|
@ -52,8 +46,6 @@ where
|
|||
|
||||
/// Batches all the provided subscriptions and returns the resulting
|
||||
/// [`Subscription`].
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
pub fn batch(
|
||||
subscriptions: impl IntoIterator<Item = Subscription<H, E, O>>,
|
||||
) -> Self {
|
||||
|
|
@ -66,8 +58,6 @@ where
|
|||
}
|
||||
|
||||
/// Returns the different recipes of the [`Subscription`].
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
pub fn recipes(self) -> Vec<Box<dyn Recipe<H, E, Output = O>>> {
|
||||
self.recipes
|
||||
}
|
||||
|
|
@ -75,8 +65,6 @@ where
|
|||
/// Adds a value to the [`Subscription`] context.
|
||||
///
|
||||
/// The value will be part of the identity of a [`Subscription`].
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
pub fn with<T>(mut self, value: T) -> Subscription<H, E, (T, O)>
|
||||
where
|
||||
H: 'static,
|
||||
|
|
@ -97,8 +85,6 @@ where
|
|||
}
|
||||
|
||||
/// Transforms the [`Subscription`] output with the given function.
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
pub fn map<A>(mut self, f: fn(O) -> A) -> Subscription<H, E, A>
|
||||
where
|
||||
H: 'static,
|
||||
|
|
@ -131,9 +117,6 @@ impl<I, O, H> std::fmt::Debug for Subscription<I, O, H> {
|
|||
/// by runtimes to run and identify subscriptions. You can use it to create your
|
||||
/// own!
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
/// [`Recipe`]: trait.Recipe.html
|
||||
///
|
||||
/// # Examples
|
||||
/// The repository has a couple of [examples] that use a custom [`Recipe`]:
|
||||
///
|
||||
|
|
@ -148,17 +131,11 @@ impl<I, O, H> std::fmt::Debug for Subscription<I, O, H> {
|
|||
pub trait Recipe<Hasher: std::hash::Hasher, Event> {
|
||||
/// The events that will be produced by a [`Subscription`] with this
|
||||
/// [`Recipe`].
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
/// [`Recipe`]: trait.Recipe.html
|
||||
type Output;
|
||||
|
||||
/// Hashes the [`Recipe`].
|
||||
///
|
||||
/// This is used by runtimes to uniquely identify a [`Subscription`].
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
/// [`Recipe`]: trait.Recipe.html
|
||||
fn hash(&self, state: &mut Hasher);
|
||||
|
||||
/// Executes the [`Recipe`] and produces the stream of events of its
|
||||
|
|
@ -166,9 +143,6 @@ pub trait Recipe<Hasher: std::hash::Hasher, Event> {
|
|||
///
|
||||
/// It receives some stream of generic events, which is normally defined by
|
||||
/// shells.
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
/// [`Recipe`]: trait.Recipe.html
|
||||
fn stream(
|
||||
self: Box<Self>,
|
||||
input: BoxStream<Event>,
|
||||
|
|
|
|||
|
|
@ -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,9 +50,7 @@ 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>,
|
||||
|
|
@ -132,7 +128,7 @@ where
|
|||
/// This method publishes the given event to all the subscription streams
|
||||
/// currently open.
|
||||
///
|
||||
/// [`Recipe::stream`]: trait.Recipe.html#tymethod.stream
|
||||
/// [`Recipe::stream`]: crate::subscription::Recipe::stream
|
||||
pub fn broadcast(&mut self, event: Event) {
|
||||
self.subscriptions
|
||||
.values_mut()
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ use crate::subscription::{self, Subscription};
|
|||
///
|
||||
/// The first message is produced after a `duration`, and then continues to
|
||||
/// produce more messages every `duration` after that.
|
||||
///
|
||||
/// [`Subscription`]: ../subscription/struct.Subscription.html
|
||||
pub fn every<H: std::hash::Hasher, E>(
|
||||
duration: std::time::Duration,
|
||||
) -> Subscription<H, E, std::time::Instant> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue