aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-16 10:48:23 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-16 10:48:23 -0500
commitc3aed08259c794290d8cf21fe0712b36d4c5f523 (patch)
tree3a064d859bdc258c99f554c952643eeb2f043ce4
parentb8d8dbf0ff086825ce226b02603035601fbf955f (diff)
downloadteleterm-c3aed08259c794290d8cf21fe0712b36d4c5f523.tar.gz
teleterm-c3aed08259c794290d8cf21fe0712b36d4c5f523.zip
shorter names
-rw-r--r--teleterm-web/src/lib.rs7
-rw-r--r--teleterm/src/client.rs18
-rw-r--r--teleterm/src/cmd/play.rs5
-rw-r--r--teleterm/src/cmd/record.rs5
-rw-r--r--teleterm/src/cmd/server.rs7
-rw-r--r--teleterm/src/cmd/stream.rs5
-rw-r--r--teleterm/src/cmd/watch.rs11
-rw-r--r--teleterm/src/cmd/web.rs3
-rw-r--r--teleterm/src/config.rs2
-rw-r--r--teleterm/src/key_reader.rs2
-rw-r--r--teleterm/src/oauth.rs12
-rw-r--r--teleterm/src/oauth/recurse_center.rs3
-rw-r--r--teleterm/src/prelude.rs7
-rw-r--r--teleterm/src/protocol.rs10
-rw-r--r--teleterm/src/server.rs25
-rw-r--r--teleterm/src/server/tls.rs6
-rw-r--r--teleterm/src/web/ws.rs2
17 files changed, 55 insertions, 75 deletions
diff --git a/teleterm-web/src/lib.rs b/teleterm-web/src/lib.rs
index eeba28f..be4396a 100644
--- a/teleterm-web/src/lib.rs
+++ b/teleterm-web/src/lib.rs
@@ -13,9 +13,10 @@ pub fn main() -> Result<(), JsValue> {
let ws = web_sys::WebSocket::new("ws://127.0.0.1:4145/ws")?;
- let msg_cb = Closure::wrap(Box::new(move |event: web_sys::MessageEvent| {
- log(&format!("message {:?}", event));
- }) as Box<dyn FnMut(web_sys::MessageEvent)>);
+ let msg_cb =
+ Closure::wrap(Box::new(move |event: web_sys::MessageEvent| {
+ log(&format!("message {:?}", event));
+ }) as Box<dyn FnMut(web_sys::MessageEvent)>);
ws.set_onmessage(Some(msg_cb.as_ref().unchecked_ref()));
msg_cb.forget();
diff --git a/teleterm/src/client.rs b/teleterm/src/client.rs
index 254940c..daabf7d 100644
--- a/teleterm/src/client.rs
+++ b/teleterm/src/client.rs
@@ -19,7 +19,7 @@ enum ReadSocket<
Connected(crate::protocol::FramedReadHalf<S>),
Reading(
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = (
crate::protocol::Message,
crate::protocol::FramedReadHalf<S>,
@@ -31,7 +31,7 @@ enum ReadSocket<
Processing(
crate::protocol::FramedReadHalf<S>,
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = crate::protocol::Message,
Error = Error,
> + Send,
@@ -45,14 +45,13 @@ enum WriteSocket<
NotConnected,
Connecting(
Box<
- dyn futures::future::Future<Item = S, Error = crate::error::Error>
- + Send,
+ dyn futures::Future<Item = S, Error = crate::error::Error> + Send,
>,
),
Connected(crate::protocol::FramedWriteHalf<S>),
Writing(
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = crate::protocol::FramedWriteHalf<S>,
Error = Error,
> + Send,
@@ -68,8 +67,7 @@ pub enum Event {
pub type Connector<S> = Box<
dyn Fn() -> Box<
- dyn futures::future::Future<Item = S, Error = crate::error::Error>
- + Send,
+ dyn futures::Future<Item = S, Error = crate::error::Error> + Send,
> + Send,
>;
@@ -227,7 +225,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
component_future::Async<Option<Event>>,
Option<
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = crate::protocol::Message,
Error = Error,
> + Send,
@@ -284,7 +282,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
id: &str,
) -> Result<
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = crate::protocol::Message,
Error = Error,
> + Send,
@@ -584,7 +582,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
#[must_use = "streams do nothing unless polled"]
impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
- futures::stream::Stream for Client<S>
+ futures::Stream for Client<S>
{
type Item = Event;
type Error = Error;
diff --git a/teleterm/src/cmd/play.rs b/teleterm/src/cmd/play.rs
index 3d36d18..93a2ca6 100644
--- a/teleterm/src/cmd/play.rs
+++ b/teleterm/src/cmd/play.rs
@@ -24,8 +24,7 @@ impl crate::config::Config for Config {
fn run(
&self,
- ) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send>
- {
+ ) -> Box<dyn futures::Future<Item = (), Error = Error> + Send> {
Box::new(PlaySession::new(
&self.ttyrec.filename,
self.play.play_at_start,
@@ -936,7 +935,7 @@ impl PlaySession {
}
#[must_use = "futures do nothing unless polled"]
-impl futures::future::Future for PlaySession {
+impl futures::Future for PlaySession {
type Item = ();
type Error = Error;
diff --git a/teleterm/src/cmd/record.rs b/teleterm/src/cmd/record.rs
index 7cfe52a..735c372 100644
--- a/teleterm/src/cmd/record.rs
+++ b/teleterm/src/cmd/record.rs
@@ -22,8 +22,7 @@ impl crate::config::Config for Config {
fn run(
&self,
- ) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send>
- {
+ ) -> Box<dyn futures::Future<Item = (), Error = Error> + Send> {
Box::new(RecordSession::new(
&self.ttyrec.filename,
&self.command.command,
@@ -249,7 +248,7 @@ impl RecordSession {
}
#[must_use = "futures do nothing unless polled"]
-impl futures::future::Future for RecordSession {
+impl futures::Future for RecordSession {
type Item = ();
type Error = Error;
diff --git a/teleterm/src/cmd/server.rs b/teleterm/src/cmd/server.rs
index c4d2075..7eff187 100644
--- a/teleterm/src/cmd/server.rs
+++ b/teleterm/src/cmd/server.rs
@@ -27,8 +27,7 @@ impl crate::config::Config for Config {
fn run(
&self,
- ) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send>
- {
+ ) -> Box<dyn futures::Future<Item = (), Error = Error> + Send> {
if let Some(tls_identity_file) = &self.server.tls_identity_file {
create_server_tls(
self.server.listen_address,
@@ -81,7 +80,7 @@ fn create_server(
>,
uid: Option<users::uid_t>,
gid: Option<users::gid_t>,
-) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send> {
+) -> Box<dyn futures::Future<Item = (), Error = Error> + Send> {
let listener = match listen(address, uid, gid) {
Ok(listener) => listener,
Err(e) => return Box::new(futures::future::err(e)),
@@ -111,7 +110,7 @@ fn create_server_tls(
>,
uid: Option<users::uid_t>,
gid: Option<users::gid_t>,
-) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send> {
+) -> Box<dyn futures::Future<Item = (), Error = Error> + Send> {
let tls_acceptor = match accept_tls(tls_identity_file) {
Ok(acceptor) => acceptor,
Err(e) => return Box::new(futures::future::err(e)),
diff --git a/teleterm/src/cmd/stream.rs b/teleterm/src/cmd/stream.rs
index 11d3873..0ca8dac 100644
--- a/teleterm/src/cmd/stream.rs
+++ b/teleterm/src/cmd/stream.rs
@@ -22,8 +22,7 @@ impl crate::config::Config for Config {
fn run(
&self,
- ) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send>
- {
+ ) -> Box<dyn futures::Future<Item = (), Error = Error> + Send> {
let auth = match self.client.auth {
crate::protocol::AuthType::Plain => {
let username = self
@@ -334,7 +333,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
#[must_use = "futures do nothing unless polled"]
impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
- futures::future::Future for StreamSession<S>
+ futures::Future for StreamSession<S>
{
type Item = ();
type Error = Error;
diff --git a/teleterm/src/cmd/watch.rs b/teleterm/src/cmd/watch.rs
index d5e4a9f..fa5fdd1 100644
--- a/teleterm/src/cmd/watch.rs
+++ b/teleterm/src/cmd/watch.rs
@@ -20,8 +20,7 @@ impl crate::config::Config for Config {
fn run(
&self,
- ) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send>
- {
+ ) -> Box<dyn futures::Future<Item = (), Error = Error> + Send> {
let auth = match self.client.auth {
crate::protocol::AuthType::Plain => {
let username = self
@@ -194,10 +193,8 @@ struct WatchSession<
key_reader: crate::key_reader::KeyReader,
list_client: crate::client::Client<S>,
resizer: Box<
- dyn futures::stream::Stream<
- Item = (u16, u16),
- Error = crate::error::Error,
- > + Send,
+ dyn futures::Stream<Item = (u16, u16), Error = crate::error::Error>
+ + Send,
>,
state: State<S>,
raw_screen: Option<crossterm::screen::RawScreen>,
@@ -644,7 +641,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
#[must_use = "futures do nothing unless polled"]
impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
- futures::future::Future for WatchSession<S>
+ futures::Future for WatchSession<S>
{
type Item = ();
type Error = Error;
diff --git a/teleterm/src/cmd/web.rs b/teleterm/src/cmd/web.rs
index a37468b..c39582b 100644
--- a/teleterm/src/cmd/web.rs
+++ b/teleterm/src/cmd/web.rs
@@ -16,8 +16,7 @@ impl crate::config::Config for Config {
fn run(
&self,
- ) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send>
- {
+ ) -> Box<dyn futures::Future<Item = (), Error = Error> + Send> {
Box::new(
gotham::init_server(
self.web.listen_address,
diff --git a/teleterm/src/config.rs b/teleterm/src/config.rs
index 20528c9..42b4ec4 100644
--- a/teleterm/src/config.rs
+++ b/teleterm/src/config.rs
@@ -39,7 +39,7 @@ pub trait Config: std::fmt::Debug {
) -> Result<()>;
fn run(
&self,
- ) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send>;
+ ) -> Box<dyn futures::Future<Item = (), Error = Error> + Send>;
}
pub fn config(
diff --git a/teleterm/src/key_reader.rs b/teleterm/src/key_reader.rs
index 9a35e2d..76398f3 100644
--- a/teleterm/src/key_reader.rs
+++ b/teleterm/src/key_reader.rs
@@ -16,7 +16,7 @@ impl KeyReader {
}
}
-impl futures::stream::Stream for KeyReader {
+impl futures::Stream for KeyReader {
type Item = crossterm::input::InputEvent;
type Error = Error;
diff --git a/teleterm/src/oauth.rs b/teleterm/src/oauth.rs
index 26aecbc..680b6f4 100644
--- a/teleterm/src/oauth.rs
+++ b/teleterm/src/oauth.rs
@@ -32,8 +32,7 @@ pub trait Oauth {
fn get_access_token_from_auth_code(
&self,
code: &str,
- ) -> Box<dyn futures::future::Future<Item = String, Error = Error> + Send>
- {
+ ) -> Box<dyn futures::Future<Item = String, Error = Error> + Send> {
let token_cache_file = self.server_token_file(false).unwrap();
let fut = self
.client()
@@ -53,8 +52,7 @@ pub trait Oauth {
fn get_access_token_from_refresh_token(
&self,
token: &str,
- ) -> Box<dyn futures::future::Future<Item = String, Error = Error> + Send>
- {
+ ) -> Box<dyn futures::Future<Item = String, Error = Error> + Send> {
let token_cache_file = self.server_token_file(false).unwrap();
let fut = self
.client()
@@ -76,13 +74,13 @@ pub trait Oauth {
fn get_username_from_access_token(
self: Box<Self>,
token: &str,
- ) -> Box<dyn futures::future::Future<Item = String, Error = Error> + Send>;
+ ) -> Box<dyn futures::Future<Item = String, Error = Error> + Send>;
}
pub fn save_client_auth_id(
auth: crate::protocol::AuthType,
id: &str,
-) -> impl futures::future::Future<Item = (), Error = Error> {
+) -> impl futures::Future<Item = (), Error = Error> {
let id_file = client_id_file(auth, false).unwrap();
let id = id.to_string();
tokio::fs::File::create(id_file.clone())
@@ -119,7 +117,7 @@ fn client_id_file(
fn cache_refresh_token(
token_cache_file: std::path::PathBuf,
token: &oauth2::basic::BasicTokenResponse,
-) -> Box<dyn futures::future::Future<Item = (), Error = Error> + Send> {
+) -> Box<dyn futures::Future<Item = (), Error = Error> + Send> {
let token_data = format!(
"{}\n{}\n",
token.refresh_token().unwrap().secret(),
diff --git a/teleterm/src/oauth/recurse_center.rs b/teleterm/src/oauth/recurse_center.rs
index 2b9f7f7..6eeb69c 100644
--- a/teleterm/src/oauth/recurse_center.rs
+++ b/teleterm/src/oauth/recurse_center.rs
@@ -44,8 +44,7 @@ impl super::Oauth for RecurseCenter {
fn get_username_from_access_token(
self: Box<Self>,
token: &str,
- ) -> Box<dyn futures::future::Future<Item = String, Error = Error> + Send>
- {
+ ) -> Box<dyn futures::Future<Item = String, Error = Error> + Send> {
let fut = reqwest::r#async::Client::new()
.get("https://www.recurse.com/api/v1/profiles/me")
.bearer_auth(token)
diff --git a/teleterm/src/prelude.rs b/teleterm/src/prelude.rs
index 1bd29b7..e47820e 100644
--- a/teleterm/src/prelude.rs
+++ b/teleterm/src/prelude.rs
@@ -1,8 +1,5 @@
-pub use futures::future::Future as _;
-pub use futures::sink::Sink as _;
-pub use futures::stream::Stream as _;
-pub use snafu::futures01::stream::StreamExt as _;
-pub use snafu::futures01::FutureExt as _;
+pub use futures::{Future as _, Sink as _, Stream as _};
+pub use snafu::futures01::{FutureExt as _, StreamExt as _};
pub use snafu::{OptionExt as _, ResultExt as _};
pub use crate::error::{Error, Result};
diff --git a/teleterm/src/protocol.rs b/teleterm/src/protocol.rs
index 58fa396..20e987d 100644
--- a/teleterm/src/protocol.rs
+++ b/teleterm/src/protocol.rs
@@ -322,7 +322,7 @@ impl Message {
pub fn read_async<T: tokio::io::AsyncRead>(
r: FramedReader<T>,
- ) -> impl futures::future::Future<Item = (Self, FramedReader<T>), Error = Error>
+ ) -> impl futures::Future<Item = (Self, FramedReader<T>), Error = Error>
{
Packet::read_async(r).and_then(|(packet, r)| {
Self::try_from(packet).map(|msg| (msg, r))
@@ -337,8 +337,7 @@ impl Message {
pub fn write_async<T: tokio::io::AsyncWrite>(
&self,
w: FramedWriter<T>,
- ) -> impl futures::future::Future<Item = FramedWriter<T>, Error = Error>
- {
+ ) -> impl futures::Future<Item = FramedWriter<T>, Error = Error> {
Packet::from(self).write_async(w)
}
@@ -393,7 +392,7 @@ impl Packet {
fn read_async<T: tokio::io::AsyncRead>(
r: FramedReader<T>,
- ) -> impl futures::future::Future<Item = (Self, FramedReader<T>), Error = Error>
+ ) -> impl futures::Future<Item = (Self, FramedReader<T>), Error = Error>
{
r.0.into_future()
.map_err(|(e, _)| Error::ReadPacket { source: e })
@@ -428,8 +427,7 @@ impl Packet {
fn write_async<T: tokio::io::AsyncWrite>(
&self,
w: FramedWriter<T>,
- ) -> impl futures::future::Future<Item = FramedWriter<T>, Error = Error>
- {
+ ) -> impl futures::Future<Item = FramedWriter<T>, Error = Error> {
w.0.send(bytes::Bytes::from(self.as_bytes()))
.map(FramedWriter)
.context(crate::error::WritePacket)
diff --git a/teleterm/src/server.rs b/teleterm/src/server.rs
index d18fa95..4c44a01 100644
--- a/teleterm/src/server.rs
+++ b/teleterm/src/server.rs
@@ -9,7 +9,7 @@ enum ReadSocket<
Connected(crate::protocol::FramedReadHalf<S>),
Reading(
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = (
crate::protocol::Message,
crate::protocol::FramedReadHalf<S>,
@@ -21,7 +21,7 @@ enum ReadSocket<
Processing(
crate::protocol::FramedReadHalf<S>,
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = (ConnectionState, crate::protocol::Message),
Error = Error,
> + Send,
@@ -35,7 +35,7 @@ enum WriteSocket<
Connected(crate::protocol::FramedWriteHalf<S>),
Writing(
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = crate::protocol::FramedWriteHalf<S>,
Error = Error,
> + Send,
@@ -302,8 +302,7 @@ pub struct Server<
S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static,
> {
read_timeout: std::time::Duration,
- acceptor:
- Box<dyn futures::stream::Stream<Item = S, Error = Error> + Send>,
+ acceptor: Box<dyn futures::Stream<Item = S, Error = Error> + Send>,
connections: std::collections::HashMap<String, Connection<S>>,
rate_limiter: ratelimit_meter::KeyedRateLimiter<Option<String>>,
allowed_auth_types: std::collections::HashSet<crate::protocol::AuthType>,
@@ -317,9 +316,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
Server<S>
{
pub fn new(
- acceptor: Box<
- dyn futures::stream::Stream<Item = S, Error = Error> + Send,
- >,
+ acceptor: Box<dyn futures::Stream<Item = S, Error = Error> + Send>,
read_timeout: std::time::Duration,
allowed_auth_types: std::collections::HashSet<
crate::protocol::AuthType,
@@ -351,7 +348,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
) -> Result<
Option<
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = (ConnectionState, crate::protocol::Message),
Error = Error,
> + Send,
@@ -597,7 +594,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
) -> Result<
Option<
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = (ConnectionState, crate::protocol::Message),
Error = Error,
> + Send,
@@ -634,7 +631,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
) -> Result<
Option<
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = (ConnectionState, crate::protocol::Message),
Error = Error,
> + Send,
@@ -659,7 +656,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
) -> Result<
Option<
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = (ConnectionState, crate::protocol::Message),
Error = Error,
> + Send,
@@ -756,7 +753,7 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
) -> Result<
Option<
Box<
- dyn futures::future::Future<
+ dyn futures::Future<
Item = (ConnectionState, crate::protocol::Message),
Error = Error,
> + Send,
@@ -1062,7 +1059,7 @@ fn classify_connection_error(e: Error) -> component_future::Poll<(), Error> {
#[must_use = "futures do nothing unless polled"]
impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static>
- futures::future::Future for Server<S>
+ futures::Future for Server<S>
{
type Item = ();
type Error = Error;
diff --git a/teleterm/src/server/tls.rs b/teleterm/src/server/tls.rs
index 39e63ba..28b9b28 100644
--- a/teleterm/src/server/tls.rs
+++ b/teleterm/src/server/tls.rs
@@ -3,7 +3,7 @@ use crate::prelude::*;
pub struct Server {
server: super::Server<tokio_tls::TlsStream<tokio::net::TcpStream>>,
acceptor: Box<
- dyn futures::stream::Stream<
+ dyn futures::Stream<
Item = tokio_tls::Accept<tokio::net::TcpStream>,
Error = Error,
> + Send,
@@ -17,7 +17,7 @@ pub struct Server {
impl Server {
pub fn new(
acceptor: Box<
- dyn futures::stream::Stream<
+ dyn futures::Stream<
Item = tokio_tls::Accept<tokio::net::TcpStream>,
Error = Error,
> + Send,
@@ -121,7 +121,7 @@ impl Server {
}
#[must_use = "futures do nothing unless polled"]
-impl futures::future::Future for Server {
+impl futures::Future for Server {
type Item = ();
type Error = Error;
diff --git a/teleterm/src/web/ws.rs b/teleterm/src/web/ws.rs
index ad47147..ef11641 100644
--- a/teleterm/src/web/ws.rs
+++ b/teleterm/src/web/ws.rs
@@ -1,6 +1,6 @@
// from https://github.com/gotham-rs/gotham/blob/master/examples/websocket/src/main.rs
-use futures::future::Future as _;
+use futures::Future as _;
const PROTO_WEBSOCKET: &str = "websocket";
const SEC_WEBSOCKET_KEY: &str = "Sec-WebSocket-Key";