Run cargo fmt

This commit is contained in:
Tim Kuehn
2020-08-18 02:55:24 -07:00
parent aa7b875b1a
commit 7fda862fb8
2 changed files with 16 additions and 7 deletions

View File

@@ -7,9 +7,9 @@
use clap::{App, Arg};
use std::{io, net::SocketAddr};
use tarpc::{client, context};
use tokio::net::TcpStream;
use tokio_serde::formats::Json;
use tokio_util::codec::LengthDelimitedCodec;
use tokio::net::TcpStream;
#[tokio::main]
async fn main() -> io::Result<()> {
@@ -47,11 +47,12 @@ async fn main() -> io::Result<()> {
let conn = TcpStream::connect(server_addr).await?;
let transport = tarpc::serde_transport::new(
LengthDelimitedCodec::builder().max_frame_length(4294967296).new_framed(conn),
LengthDelimitedCodec::builder()
.max_frame_length(4294967296)
.new_framed(conn),
Json::default(),
);
// WorldClient is generated by the service attribute. It has a constructor `new` that takes a
// config and any Transport as input.
let mut client = service::WorldClient::new(client::Config::default(), transport).spawn()?;

View File

@@ -14,7 +14,10 @@ use serde::{Deserialize, Serialize};
use std::{error::Error, io, pin::Pin};
use tokio::io::{AsyncRead, AsyncWrite};
use tokio_serde::{Framed as SerdeFramed, *};
use tokio_util::codec::{length_delimited::{self, LengthDelimitedCodec}, Framed};
use tokio_util::codec::{
length_delimited::{self, LengthDelimitedCodec},
Framed,
};
/// A transport that serializes to, and deserializes from, a byte stream.
#[pin_project]
@@ -91,8 +94,10 @@ fn convert<E: Into<Box<dyn Error + Send + Sync>>>(
}
/// Constructs a new transport from a framed transport and a serialization codec.
pub fn new<S, Item, SinkItem, Codec>(framed_io: Framed<S, LengthDelimitedCodec>, codec: Codec)
-> Transport<S, Item, SinkItem, Codec>
pub fn new<S, Item, SinkItem, Codec>(
framed_io: Framed<S, LengthDelimitedCodec>,
codec: Codec,
) -> Transport<S, Item, SinkItem, Codec>
where
S: AsyncWrite + AsyncRead,
Item: for<'de> Deserialize<'de>,
@@ -158,7 +163,10 @@ pub mod tcp {
SinkItem: Serialize,
Codec: Serializer<SinkItem> + Deserializer<Item>,
{
Ok(new(Framed::new(TcpStream::connect(addr).await?, config), codec))
Ok(new(
Framed::new(TcpStream::connect(addr).await?, config),
codec,
))
}
/// Connects to `addr`, wrapping the connection in a JSON transport.