mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-01-07 03:56:48 +01:00
Merge pull request #246 from google/rustfmt
Reformat all code using rustfmt
This commit is contained in:
@@ -218,8 +218,16 @@ mod tests {
|
||||
let transport = Transport::<_, String, String>::from(Cursor::new(&mut *writer));
|
||||
pin_mut!(transport);
|
||||
|
||||
assert_matches!(transport.as_mut().poll_ready(&mut ctx()), Poll::Ready(Ok(())));
|
||||
assert_matches!(transport .as_mut() .start_send("Test one, check check.".into()), Ok(()));
|
||||
assert_matches!(
|
||||
transport.as_mut().poll_ready(&mut ctx()),
|
||||
Poll::Ready(Ok(()))
|
||||
);
|
||||
assert_matches!(
|
||||
transport
|
||||
.as_mut()
|
||||
.start_send("Test one, check check.".into()),
|
||||
Ok(())
|
||||
);
|
||||
assert_matches!(transport.poll_flush(&mut ctx()), Poll::Ready(Ok(())));
|
||||
assert_eq!(
|
||||
writer,
|
||||
|
||||
@@ -201,12 +201,15 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Transport;
|
||||
use assert_matches::assert_matches;
|
||||
use futures::{Sink, Stream};
|
||||
use futures_test::task::noop_waker_ref;
|
||||
use pin_utils::pin_mut;
|
||||
use std::{io::Cursor, task::{Context, Poll}};
|
||||
use super::Transport;
|
||||
use std::{
|
||||
io::Cursor,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
fn ctx() -> Context<'static> {
|
||||
Context::from_waker(&noop_waker_ref())
|
||||
@@ -230,8 +233,16 @@ mod tests {
|
||||
let transport = Transport::<_, String, String>::from(Cursor::new(&mut *writer));
|
||||
pin_mut!(transport);
|
||||
|
||||
assert_matches!(transport.as_mut().poll_ready(&mut ctx()), Poll::Ready(Ok(())));
|
||||
assert_matches!(transport.as_mut().start_send("Test one, check check.".into()), Ok(()));
|
||||
assert_matches!(
|
||||
transport.as_mut().poll_ready(&mut ctx()),
|
||||
Poll::Ready(Ok(()))
|
||||
);
|
||||
assert_matches!(
|
||||
transport
|
||||
.as_mut()
|
||||
.start_send("Test one, check check.".into()),
|
||||
Ok(())
|
||||
);
|
||||
assert_matches!(transport.poll_flush(&mut ctx()), Poll::Ready(Ok(())));
|
||||
assert_eq!(writer, b"\x00\x00\x00\x18\"Test one, check check.\"");
|
||||
}
|
||||
|
||||
@@ -4,12 +4,7 @@
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
#![feature(
|
||||
weak_counts,
|
||||
non_exhaustive,
|
||||
async_await,
|
||||
trait_alias,
|
||||
)]
|
||||
#![feature(weak_counts, non_exhaustive, async_await, trait_alias)]
|
||||
#![deny(missing_docs, missing_debug_implementations)]
|
||||
|
||||
//! An RPC framework providing client and server.
|
||||
|
||||
@@ -456,7 +456,10 @@ fn channel_filter_poll_closed_channels() {
|
||||
assert_eq!(filter.key_counts.len(), 1);
|
||||
|
||||
drop(channel);
|
||||
assert_matches!(filter.as_mut().poll_closed_channels(&mut ctx()), Poll::Ready(()));
|
||||
assert_matches!(
|
||||
filter.as_mut().poll_closed_channels(&mut ctx()),
|
||||
Poll::Ready(())
|
||||
);
|
||||
assert!(filter.key_counts.is_empty());
|
||||
}
|
||||
|
||||
|
||||
@@ -349,10 +349,7 @@ where
|
||||
self.transport().poll_ready(cx)
|
||||
}
|
||||
|
||||
fn start_send(
|
||||
mut self: Pin<&mut Self>,
|
||||
response: Response<Resp>,
|
||||
) -> Result<(), Self::Error> {
|
||||
fn start_send(mut self: Pin<&mut Self>, response: Response<Resp>) -> Result<(), Self::Error> {
|
||||
if self
|
||||
.as_mut()
|
||||
.in_flight_requests()
|
||||
@@ -521,19 +518,21 @@ where
|
||||
let trace_id = *ctx.trace_id();
|
||||
let response = self.as_mut().f().clone()(ctx, request);
|
||||
let response = deadline_compat::Deadline::new(response, Instant::now() + timeout).then(
|
||||
move |result| async move {
|
||||
let response = Response {
|
||||
request_id,
|
||||
message: match result {
|
||||
Ok(message) => Ok(message),
|
||||
Err(e) => Err(make_server_error(e, trace_id, deadline)),
|
||||
},
|
||||
};
|
||||
trace!("[{}] Sending response.", trace_id);
|
||||
response_tx
|
||||
.send((ctx, response))
|
||||
.unwrap_or_else(|_| ())
|
||||
.await;
|
||||
move |result| {
|
||||
async move {
|
||||
let response = Response {
|
||||
request_id,
|
||||
message: match result {
|
||||
Ok(message) => Ok(message),
|
||||
Err(e) => Err(make_server_error(e, trace_id, deadline)),
|
||||
},
|
||||
};
|
||||
trace!("[{}] Sending response.", trace_id);
|
||||
response_tx
|
||||
.send((ctx, response))
|
||||
.unwrap_or_else(|_| ())
|
||||
.await;
|
||||
}
|
||||
},
|
||||
);
|
||||
let abort_registration = self.as_mut().channel().start_request(request_id);
|
||||
|
||||
@@ -42,10 +42,7 @@ impl<In, Resp> Sink<Response<Resp>> for FakeChannel<In, Response<Resp>> {
|
||||
self.sink().poll_ready(cx).map_err(|e| match e {})
|
||||
}
|
||||
|
||||
fn start_send(
|
||||
mut self: Pin<&mut Self>,
|
||||
response: Response<Resp>,
|
||||
) -> Result<(), Self::Error> {
|
||||
fn start_send(mut self: Pin<&mut Self>, response: Response<Resp>) -> Result<(), Self::Error> {
|
||||
self.as_mut()
|
||||
.in_flight_requests()
|
||||
.remove(&response.request_id);
|
||||
|
||||
@@ -4,11 +4,7 @@
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
#![feature(
|
||||
async_await,
|
||||
existential_type,
|
||||
proc_macro_hygiene
|
||||
)]
|
||||
#![feature(async_await, existential_type, proc_macro_hygiene)]
|
||||
|
||||
use futures::{
|
||||
future::{self, Ready},
|
||||
|
||||
@@ -4,11 +4,7 @@
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
#![feature(
|
||||
existential_type,
|
||||
async_await,
|
||||
proc_macro_hygiene
|
||||
)]
|
||||
#![feature(existential_type, async_await, proc_macro_hygiene)]
|
||||
|
||||
use crate::{add::Service as AddService, double::Service as DoubleService};
|
||||
use futures::{
|
||||
|
||||
Reference in New Issue
Block a user