Skip to content

Commit

Permalink
Move docs of future and stream in Task
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jul 10, 2024
1 parent e86920b commit 8efe161
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions runtime/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,6 @@ impl<T> Task<T> {
Self::stream(stream.map(f))
}

/// Creates a new [`Task`] that runs the given [`Future`] and produces
/// its output.
pub fn future(future: impl Future<Output = T> + MaybeSend + 'static) -> Self
where
T: 'static,
{
Self::stream(stream::once(future))
}

/// Creates a new [`Task`] that runs the given [`Stream`] and produces
/// each of its items.
pub fn stream(stream: impl Stream<Item = T> + MaybeSend + 'static) -> Self
where
T: 'static,
{
Self(Some(boxed_stream(stream.map(Action::Output))))
}

/// Combines the given tasks and produces a single [`Task`] that will run all of them
/// in parallel.
pub fn batch(tasks: impl IntoIterator<Item = Self>) -> Self
Expand Down Expand Up @@ -176,6 +158,24 @@ impl<T> Task<T> {
))),
}
}

/// Creates a new [`Task`] that runs the given [`Future`] and produces
/// its output.
pub fn future(future: impl Future<Output = T> + MaybeSend + 'static) -> Self
where
T: 'static,
{
Self::stream(stream::once(future))
}

/// Creates a new [`Task`] that runs the given [`Stream`] and produces
/// each of its items.
pub fn stream(stream: impl Stream<Item = T> + MaybeSend + 'static) -> Self
where
T: 'static,
{
Self(Some(boxed_stream(stream.map(Action::Output))))
}
}

impl<T> Task<Option<T>> {
Expand Down

0 comments on commit 8efe161

Please sign in to comment.