diff --git a/tarpc/rustfmt.toml b/tarpc/rustfmt.toml new file mode 100644 index 0000000..44148a2 --- /dev/null +++ b/tarpc/rustfmt.toml @@ -0,0 +1 @@ +reorder_imports = true diff --git a/tarpc/src/protocol.rs b/tarpc/src/protocol.rs index f984c48..3e07d39 100644 --- a/tarpc/src/protocol.rs +++ b/tarpc/src/protocol.rs @@ -15,9 +15,9 @@ use std::convert; use std::collections::HashMap; use std::marker::PhantomData; use std::mem; -use std::net::{TcpListener, TcpStream, SocketAddr, ToSocketAddrs}; +use std::net::{SocketAddr, TcpListener, TcpStream, ToSocketAddrs}; use std::sync::{Arc, Condvar, Mutex}; -use std::sync::mpsc::{channel, Sender, TryRecvError}; +use std::sync::mpsc::{Sender, TryRecvError, channel}; use std::sync::atomic::{AtomicBool, Ordering}; use std::time::Duration; use std::thread::{self, JoinHandle}; @@ -97,7 +97,9 @@ impl InflightRpcs { } -struct ConnectionHandler<'a, S> where S: Serve { +struct ConnectionHandler<'a, S> + where S: Serve +{ read_stream: TcpStream, write_stream: Mutex, shutdown: &'a AtomicBool, @@ -123,8 +125,7 @@ impl<'a, S> ConnectionHandler<'a, S> where S: Serve { bincode::serde::deserialize_from(read_stream, bincode::SizeLimit::Infinite) } - fn handle_conn(&mut self) -> Result<()> - { + fn handle_conn(&mut self) -> Result<()> { let ConnectionHandler { ref mut read_stream, ref write_stream, @@ -225,7 +226,10 @@ impl ServeHandle { } /// Start -pub fn serve_async(addr: A, server: S, read_timeout: Option) -> io::Result +pub fn serve_async(addr: A, + server: S, + read_timeout: Option) + -> io::Result where A: ToSocketAddrs, S: 'static + Serve { @@ -487,7 +491,7 @@ mod test { extern crate env_logger; use super::{Client, Serve, serve_async}; - use std::sync::{Arc, Mutex, Barrier}; + use std::sync::{Arc, Barrier, Mutex}; use std::thread; use std::time::Duration;