cargo fmt

This commit is contained in:
Tim Kuehn
2018-11-06 17:01:27 -08:00
parent 4d2d3f24c6
commit 0cc976b729
8 changed files with 22 additions and 64 deletions

View File

@@ -6,13 +6,7 @@
//! A TCP [`Transport`] that serializes as bincode.
#![feature(
futures_api,
pin,
arbitrary_self_types,
await_macro,
async_await
)]
#![feature(futures_api, pin, arbitrary_self_types, await_macro, async_await)]
#![deny(missing_docs, missing_debug_implementations)]
use self::compat::Compat;

View File

@@ -4,13 +4,7 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
#![feature(
futures_api,
pin,
arbitrary_self_types,
await_macro,
async_await
)]
#![feature(futures_api, pin, arbitrary_self_types, await_macro, async_await)]
use clap::{App, Arg};
use futures::{compat::TokioDefaultSpawner, prelude::*};

View File

@@ -4,13 +4,7 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
#![feature(
futures_api,
pin,
arbitrary_self_types,
await_macro,
async_await
)]
#![feature(futures_api, pin, arbitrary_self_types, await_macro, async_await)]
use clap::{App, Arg};
use futures::{

View File

@@ -6,9 +6,8 @@
use crate::{
context,
PollIo,
util::{deadline_compat, AsDuration, Compact},
ClientMessage, ClientMessageKind, Request, Response, Transport,
ClientMessage, ClientMessageKind, PollIo, Request, Response, Transport,
};
use fnv::FnvHashMap;
use futures::{

View File

@@ -12,7 +12,7 @@
pin,
arbitrary_self_types,
await_macro,
async_await,
async_await
)]
#![deny(missing_docs, missing_debug_implementations)]
@@ -50,10 +50,7 @@ use std::{cell::RefCell, io, sync::Once, time::SystemTime};
/// A message from a client to a server.
#[derive(Debug)]
#[cfg_attr(
feature = "serde1",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct ClientMessage<T> {
/// The trace context associates the message with a specific chain of causally-related actions,
@@ -65,10 +62,7 @@ pub struct ClientMessage<T> {
/// Different messages that can be sent from a client to a server.
#[derive(Debug)]
#[cfg_attr(
feature = "serde1",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum ClientMessageKind<T> {
/// A request initiated by a user. The server responds to a request by invoking a
@@ -90,10 +84,7 @@ pub enum ClientMessageKind<T> {
/// A request from a client to a server.
#[derive(Debug)]
#[cfg_attr(
feature = "serde1",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct Request<T> {
/// Uniquely identifies the request across all requests sent over a single channel.
@@ -115,10 +106,7 @@ pub struct Request<T> {
/// A response from a server to a client.
#[derive(Debug, PartialEq, Eq)]
#[cfg_attr(
feature = "serde1",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct Response<T> {
/// The ID of the request being responded to.
@@ -129,10 +117,7 @@ pub struct Response<T> {
/// An error response from a server to a client.
#[derive(Debug, PartialEq, Eq)]
#[cfg_attr(
feature = "serde1",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct ServerError {
#[cfg_attr(

View File

@@ -5,10 +5,9 @@
// https://opensource.org/licenses/MIT.
use crate::{
PollIo,
server::{Channel, Config},
util::Compact,
ClientMessage, Response, Transport,
ClientMessage, PollIo, Response, Transport,
};
use fnv::FnvHashMap;
use futures::{
@@ -230,10 +229,7 @@ where
{
type Item = io::Result<Channel<Req, Resp, T>>;
fn poll_next(
mut self: Pin<&mut Self>,
cx: &LocalWaker,
) -> PollIo<Channel<Req, Resp, T>> {
fn poll_next(mut self: Pin<&mut Self>, cx: &LocalWaker) -> PollIo<Channel<Req, Resp, T>> {
loop {
match (self.poll_listener(cx)?, self.poll_closed_connections(cx)?) {
(Poll::Ready(Some(NewConnection::Accepted(channel))), _) => {

View File

@@ -181,7 +181,8 @@ where
Req: Send,
Resp: Send,
T: Transport<Item = ClientMessage<Req>, SinkItem = Response<Resp>> + Send,
{}
{
}
/// Responds to all requests with `request_handler`.
/// The server end of an open connection with a client.
@@ -402,7 +403,11 @@ where
match ready!(self.pending_responses().poll_next(cx)) {
Some((ctx, response)) => {
if self.in_flight_requests().remove(&response.request_id).is_some() {
if self
.in_flight_requests()
.remove(&response.request_id)
.is_some()
{
self.in_flight_requests().compact(0.1);
}
trace!(

View File

@@ -27,10 +27,7 @@ use std::{
/// Consists of a span identifying an event, an optional parent span identifying a causal event
/// that triggered the current span, and a trace with which all related spans are associated.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Context {
/// An identifier of the trace associated with the current context. A trace ID is typically
/// created at a root span and passed along through all causal events.
@@ -50,18 +47,12 @@ pub struct Context {
/// A 128-bit UUID identifying a trace. All spans caused by the same originating span share the
/// same trace ID.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TraceId(u128);
/// A 64-bit identifier of a span within a trace. The identifier is unique within the span's trace.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SpanId(u64);
impl Context {