Skip to content

Commit

Permalink
Merge pull request snapview#86 from vivint-smarthome/minimize-deps
Browse files Browse the repository at this point in the history
build(deps): minimize unnecessary dependencies by using `futures-{channel,util}` directly instead of `futures`
  • Loading branch information
daniel-abramov committed Feb 23, 2020
2 parents 2357dc8 + 6d33192 commit 1a2a99a
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 21 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ stream = []

[dependencies]
log = "0.4"
futures = "0.3"
futures-util = { version = "0.3", default-features = false, features = ["async-await", "sink", "std"] }
pin-project = "0.4"
tokio = { version = "0.2", default-features = false, features = ["io-util"] }

Expand All @@ -36,6 +36,7 @@ optional = true
version = "0.3"

[dev-dependencies]
futures-channel = "0.3"
tokio = { version = "0.2", default-features = false, features = ["io-std", "macros", "stream", "time"] }
url = "2.0.0"
env_logger = "0.7"
2 changes: 1 addition & 1 deletion examples/autobahn-client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures::{SinkExt, StreamExt};
use futures_util::{SinkExt, StreamExt};
use log::*;
use tokio_tungstenite::{connect_async, tungstenite::Error, tungstenite::Result};
use url::Url;
Expand Down
2 changes: 1 addition & 1 deletion examples/autobahn-server.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures::{SinkExt, StreamExt};
use futures_util::{SinkExt, StreamExt};
use log::*;
use std::net::SocketAddr;
use tokio::net::{TcpListener, TcpStream};
Expand Down
6 changes: 3 additions & 3 deletions examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use std::env;

use futures::{future, pin_mut, StreamExt};
use futures_util::{future, pin_mut, StreamExt};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio_tungstenite::connect_async;
use tungstenite::protocol::Message;
Expand All @@ -25,7 +25,7 @@ async fn main() {

let url = url::Url::parse(&connect_addr).unwrap();

let (stdin_tx, stdin_rx) = futures::channel::mpsc::unbounded();
let (stdin_tx, stdin_rx) = futures_channel::mpsc::unbounded();
tokio::spawn(read_stdin(stdin_tx));

let (ws_stream, _) = connect_async(url).await.expect("Failed to connect");
Expand All @@ -47,7 +47,7 @@ async fn main() {

// Our helper method which will read data from stdin and send it along the
// sender provided.
async fn read_stdin(tx: futures::channel::mpsc::UnboundedSender<Message>) {
async fn read_stdin(tx: futures_channel::mpsc::UnboundedSender<Message>) {
let mut stdin = tokio::io::stdin();
loop {
let mut buf = vec![0; 1024];
Expand Down
2 changes: 1 addition & 1 deletion examples/echo-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use std::{env, io::Error};

use futures::StreamExt;
use futures_util::StreamExt;
use log::info;
use tokio::net::{TcpListener, TcpStream};

Expand Down
4 changes: 2 additions & 2 deletions examples/interval-server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use futures::future::{select, Either};
use futures::{SinkExt, StreamExt};
use futures_util::future::{select, Either};
use futures_util::{SinkExt, StreamExt};
use log::*;
use std::net::SocketAddr;
use std::time::Duration;
Expand Down
4 changes: 2 additions & 2 deletions examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ use std::{
sync::{Arc, Mutex},
};

use futures::{
channel::mpsc::{unbounded, UnboundedSender},
use futures_util::{
future, pin_mut,
stream::TryStreamExt,
StreamExt,
};
use futures_channel::mpsc::{unbounded, UnboundedSender};

use tokio::net::{TcpListener, TcpStream};
use tungstenite::protocol::Message;
Expand Down
2 changes: 1 addition & 1 deletion src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::{Read, Write};
use std::pin::Pin;
use std::task::{Context, Poll};

use futures::task;
use futures_util::task;
use std::sync::Arc;
use tokio::io::{AsyncRead, AsyncWrite};
use tungstenite::Error as WsError;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mod stream;
use std::io::{Read, Write};

use compat::{cvt, AllowStd, ContextWaker};
use futures::{Sink, SinkExt, Stream};
use futures_util::{sink::{Sink, SinkExt}, stream::Stream};
use log::*;
use std::pin::Pin;
use std::task::{Context, Poll};
Expand Down Expand Up @@ -259,7 +259,7 @@ where

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
trace!("{}:{} Stream.poll_next", file!(), line!());
match futures::ready!(self.with_context(Some((ContextWaker::Read, cx)), |s| {
match futures_util::ready!(self.with_context(Some((ContextWaker::Read, cx)), |s| {
trace!(
"{}:{} Stream.with_context poll_next -> read_message()",
file!(),
Expand Down
12 changes: 6 additions & 6 deletions tests/communication.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures::{SinkExt, StreamExt};
use futures_util::{SinkExt, StreamExt};
use log::*;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::net::{TcpListener, TcpStream};
Expand All @@ -7,7 +7,7 @@ use tungstenite::Message;

async fn run_connection<S>(
connection: WebSocketStream<S>,
msg_tx: futures::channel::oneshot::Sender<Vec<Message>>,
msg_tx: futures_channel::oneshot::Sender<Vec<Message>>,
) where
S: AsyncRead + AsyncWrite + Unpin,
{
Expand All @@ -26,8 +26,8 @@ async fn run_connection<S>(
async fn communication() {
let _ = env_logger::try_init();

let (con_tx, con_rx) = futures::channel::oneshot::channel();
let (msg_tx, msg_rx) = futures::channel::oneshot::channel();
let (con_tx, con_rx) = futures_channel::oneshot::channel();
let (msg_tx, msg_rx) = futures_channel::oneshot::channel();

let f = async move {
let mut listener = TcpListener::bind("0.0.0.0:12345").await.unwrap();
Expand Down Expand Up @@ -72,8 +72,8 @@ async fn communication() {
async fn split_communication() {
let _ = env_logger::try_init();

let (con_tx, con_rx) = futures::channel::oneshot::channel();
let (msg_tx, msg_rx) = futures::channel::oneshot::channel();
let (con_tx, con_rx) = futures_channel::oneshot::channel();
let (msg_tx, msg_rx) = futures_channel::oneshot::channel();

let f = async move {
let mut listener = TcpListener::bind("0.0.0.0:12346").await.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests/handshakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use tokio_tungstenite::{accept_async, client_async};

#[tokio::test]
async fn handshakes() {
let (tx, rx) = futures::channel::oneshot::channel();
let (tx, rx) = futures_channel::oneshot::channel();

let f = async move {
let mut listener = TcpListener::bind("0.0.0.0:12345").await.unwrap();
Expand Down

0 comments on commit 1a2a99a

Please sign in to comment.