mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-02-23 15:49:54 +01:00
Unify serde transports.
This PR obsoletes the JSON and Bincode transports and instead introduces a unified transport that is generic over any tokio-serde serialization format as well as AsyncRead + AsyncWrite medium. This comes with a slight hit for usability (having to manually specify the underlying transport and codec), but it can be alleviated by making custom freestanding connect and listen fns.
This commit is contained in:
committed by
Tim Kuehn
parent
f945392b5a
commit
bbbd43e282
@@ -7,6 +7,7 @@
|
||||
use clap::{App, Arg};
|
||||
use std::{io, net::SocketAddr};
|
||||
use tarpc::{client, context};
|
||||
use tokio_serde::formats::Json;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
@@ -40,7 +41,7 @@ async fn main() -> io::Result<()> {
|
||||
|
||||
let name = flags.value_of("name").unwrap().into();
|
||||
|
||||
let transport = tarpc::json_transport::connect(server_addr).await?;
|
||||
let transport = tarpc::serde_transport::tcp::connect(server_addr, Json::default()).await?;
|
||||
|
||||
// WorldClient is generated by the service attribute. It has a constructor `new` that takes a
|
||||
// config and any Transport as input.
|
||||
|
||||
Reference in New Issue
Block a user