Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Oct 23, 2023
1 parent f3892bd commit 4ce0328
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions transports/websocket/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.43.0 - unreleased

- Removes dependency on the archived `quicksink` by inlining it as a module.

## 0.42.1

Expand Down
64 changes: 32 additions & 32 deletions transports/websocket/src/quicksink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,36 @@
//
// Forked into rust-libp2p and further distributed under the MIT license.

//! Create a [`Sink`] implementation from an initial value and a closure
//! returning a [`Future`].
//!
//! This is very similar to how `futures::stream::unfold` creates a `Stream`
//! implementation from a seed value and a future-returning closure.
//!
//! # Examples
//!
//! ```no_run
//! use async_std::io;
//! use futures::prelude::*;
//! use quicksink::Action;
//!
//! quicksink::make_sink(io::stdout(), |mut stdout, action| async move {
//! match action {
//! Action::Send(x) => stdout.write_all(x).await?,
//! Action::Flush => stdout.flush().await?,
//! Action::Close => stdout.close().await?
//! }
//! Ok::<_, io::Error>(stdout)
//! });
//! ```
//!
//! # Panics
//!
//! - If any of the [`Sink`] methods produce an error, the sink transitions
//! to a failure state and none of its methods must be called afterwards or
//! else a panic will occur.
//! - If [`Sink::poll_close`] has been called, no other sink method must be
//! called afterwards or else a panic will be caused.
//!
// Create a [`Sink`] implementation from an initial value and a closure
// returning a [`Future`].
//
// This is very similar to how `futures::stream::unfold` creates a `Stream`
// implementation from a seed value and a future-returning closure.
//
// # Examples
//
// ```no_run
// use async_std::io;
// use futures::prelude::*;
// use crate::quicksink::Action;
//
// crate::quicksink::make_sink(io::stdout(), |mut stdout, action| async move {
// match action {
// Action::Send(x) => stdout.write_all(x).await?,
// Action::Flush => stdout.flush().await?,
// Action::Close => stdout.close().await?
// }
// Ok::<_, io::Error>(stdout)
// });
// ```
//
// # Panics
//
// - If any of the [`Sink`] methods produce an error, the sink transitions
// to a failure state and none of its methods must be called afterwards or
// else a panic will occur.
// - If [`Sink::poll_close`] has been called, no other sink method must be
// called afterwards or else a panic will be caused.

use futures::{ready, sink::Sink};
use pin_project_lite::pin_project;
Expand Down Expand Up @@ -293,7 +292,7 @@ where

#[cfg(test)]
mod tests {
use crate::{make_sink, Action};
use crate::quicksink::{make_sink, Action};
use async_std::{io, task};
use futures::{channel::mpsc, prelude::*, stream};

Expand All @@ -317,6 +316,7 @@ mod tests {
#[test]
fn replay() {
task::block_on(async {
#[allow(clippy::disallowed_methods)]
let (tx, rx) = mpsc::unbounded();

let sink = make_sink(tx, |mut tx, action| async move {
Expand Down

0 comments on commit 4ce0328

Please sign in to comment.