Skip to content

Commit 08750c5

Browse files
authored
chore: Consistently format imports... (#113)
2 parents 4d23e36 + 33fb08b commit 08750c5

File tree

28 files changed

+163
-151
lines changed

28 files changed

+163
-151
lines changed

examples/errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
use std::result;
2+
13
use derive_more::{Display, From, TryInto};
24
use quic_rpc::{message::RpcMsg, RpcClient, RpcServer, Service};
35
use serde::{Deserialize, Serialize};
4-
use std::result;
56

67
#[derive(Debug, Serialize, Deserialize)]
78
struct WriteRequest(String, Vec<u8>);

examples/macro.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
mod store_rpc {
2+
use std::fmt::Debug;
3+
24
use quic_rpc::rpc_service;
35
use serde::{Deserialize, Serialize};
4-
use std::fmt::Debug;
56

67
pub type Cid = [u8; 32];
78

@@ -51,9 +52,7 @@ mod store_rpc {
5152
use async_stream::stream;
5253
use futures_lite::{Stream, StreamExt};
5354
use futures_util::SinkExt;
54-
use quic_rpc::client::RpcClient;
55-
use quic_rpc::server::run_server_loop;
56-
use quic_rpc::transport::flume;
55+
use quic_rpc::{client::RpcClient, server::run_server_loop, transport::flume};
5756
use store_rpc::*;
5857

5958
#[derive(Clone)]

examples/modularize.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
//! unchanged.
99
1010
use anyhow::Result;
11+
use app::AppService;
1112
use futures_lite::StreamExt;
1213
use futures_util::SinkExt;
1314
use quic_rpc::{client::BoxedConnector, transport::flume, Listener, RpcClient, RpcServer};
1415
use tracing::warn;
1516

16-
use app::AppService;
17-
1817
#[tokio::main]
1918
async fn main() -> Result<()> {
2019
// Spawn an inmemory connection.
@@ -99,12 +98,13 @@ mod app {
9998
//!
10099
//! It could also easily compose services from other crates or internal modules.
101100
102-
use super::iroh;
103101
use anyhow::Result;
104102
use derive_more::{From, TryInto};
105103
use quic_rpc::{message::RpcMsg, server::RpcChannel, Listener, RpcClient, Service};
106104
use serde::{Deserialize, Serialize};
107105

106+
use super::iroh;
107+
108108
#[derive(Debug, Serialize, Deserialize, From, TryInto)]
109109
pub enum Request {
110110
Iroh(iroh::Request),
@@ -271,6 +271,8 @@ mod calc {
271271
//! This is a library providing a service, and a client. E.g. iroh-bytes or iroh-hypermerge.
272272
//! It does not use any `super` imports, it is completely decoupled.
273273
274+
use std::fmt::Debug;
275+
274276
use anyhow::{bail, Result};
275277
use derive_more::{From, TryInto};
276278
use futures_lite::{Stream, StreamExt};
@@ -280,7 +282,6 @@ mod calc {
280282
RpcClient, Service,
281283
};
282284
use serde::{Deserialize, Serialize};
283-
use std::fmt::Debug;
284285

285286
#[derive(Debug, Serialize, Deserialize)]
286287
pub struct AddRequest(pub i64, pub i64);
@@ -385,6 +386,12 @@ mod clock {
385386
//! This is a library providing a service, and a client. E.g. iroh-bytes or iroh-hypermerge.
386387
//! It does not use any `super` imports, it is completely decoupled.
387388
389+
use std::{
390+
fmt::Debug,
391+
sync::{Arc, RwLock},
392+
time::Duration,
393+
};
394+
388395
use anyhow::Result;
389396
use derive_more::{From, TryInto};
390397
use futures_lite::{stream::Boxed as BoxStream, Stream, StreamExt};
@@ -395,11 +402,6 @@ mod clock {
395402
RpcClient, Service,
396403
};
397404
use serde::{Deserialize, Serialize};
398-
use std::{
399-
fmt::Debug,
400-
sync::{Arc, RwLock},
401-
time::Duration,
402-
};
403405
use tokio::sync::Notify;
404406

405407
#[derive(Debug, Serialize, Deserialize)]

examples/split/client/src/main.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
#![allow(unknown_lints, non_local_definitions)]
22

3-
use std::net::SocketAddr;
4-
use std::sync::Arc;
3+
use std::{net::SocketAddr, sync::Arc};
54

65
use anyhow::Result;
7-
use futures::sink::SinkExt;
8-
use futures::stream::StreamExt;
9-
use quic_rpc::transport::quinn::QuinnConnector;
10-
use quic_rpc::RpcClient;
11-
use quinn::crypto::rustls::QuicClientConfig;
12-
use quinn::{ClientConfig, Endpoint};
6+
use futures::{sink::SinkExt, stream::StreamExt};
7+
use quic_rpc::{transport::quinn::QuinnConnector, RpcClient};
8+
use quinn::{crypto::rustls::QuicClientConfig, ClientConfig, Endpoint};
139
use types::compute::*;
1410

1511
// types::create_compute_client!(ComputeClient);

examples/split/server/src/main.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1+
use std::{net::SocketAddr, sync::Arc};
2+
13
use async_stream::stream;
24
use futures::stream::{Stream, StreamExt};
3-
use quic_rpc::server::run_server_loop;
4-
use quic_rpc::transport::quinn::QuinnListener;
5+
use quic_rpc::{server::run_server_loop, transport::quinn::QuinnListener};
56
use quinn::{Endpoint, ServerConfig};
6-
use std::net::SocketAddr;
7-
use std::sync::Arc;
8-
97
use types::compute::*;
108

119
#[derive(Clone)]

examples/split/types/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
pub mod compute {
2+
use std::fmt::Debug;
3+
24
use quic_rpc::rpc_service;
35
use serde::{Deserialize, Serialize};
4-
use std::fmt::Debug;
56

67
/// compute the square of a number
78
#[derive(Debug, Serialize, Deserialize)]

examples/store.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![allow(clippy::enum_variant_names)]
2+
use std::{fmt::Debug, result};
3+
24
use async_stream::stream;
35
use derive_more::{From, TryInto};
46
use futures_lite::{Stream, StreamExt};
@@ -9,7 +11,6 @@ use quic_rpc::{
911
*,
1012
};
1113
use serde::{Deserialize, Serialize};
12-
use std::{fmt::Debug, result};
1314

1415
type Cid = [u8; 32];
1516
#[derive(Debug, Serialize, Deserialize)]

quic-rpc-derive/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
use std::collections::{BTreeMap, HashSet};
2+
13
use proc_macro::TokenStream;
24
use proc_macro2::{Span, TokenStream as TokenStream2};
35
use quote::{quote, ToTokens};
4-
use std::collections::{BTreeMap, HashSet};
56
use syn::{
67
parse::{Parse, ParseStream},
78
parse_macro_input,

src/client.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
//! Client side api
22
//!
33
//! The main entry point is [RpcClient].
4-
use crate::{
5-
transport::{boxed::BoxableConnector, mapped::MappedConnector, StreamTypes},
6-
Connector, Service,
7-
};
8-
use futures_lite::Stream;
9-
use futures_sink::Sink;
10-
11-
use pin_project::pin_project;
124
use std::{
135
fmt::Debug,
146
marker::PhantomData,
157
pin::Pin,
168
task::{Context, Poll},
179
};
1810

11+
use futures_lite::Stream;
12+
use futures_sink::Sink;
13+
use pin_project::pin_project;
14+
15+
use crate::{
16+
transport::{boxed::BoxableConnector, mapped::MappedConnector, StreamTypes},
17+
Connector, Service,
18+
};
19+
1920
/// Type alias for a boxed connection to a specific service
2021
///
2122
/// This is a convenience type alias for a boxed connection to a specific service.

src/lib.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
//! # Example
1414
//! ```
1515
//! # async fn example() -> anyhow::Result<()> {
16-
//! use quic_rpc::{message::RpcMsg, Service, RpcClient, RpcServer};
17-
//! use serde::{Serialize, Deserialize};
1816
//! use derive_more::{From, TryInto};
17+
//! use quic_rpc::{message::RpcMsg, RpcClient, RpcServer, Service};
18+
//! use serde::{Deserialize, Serialize};
1919
//!
2020
//! // Define your messages
2121
//! #[derive(Debug, Serialize, Deserialize)]
@@ -39,21 +39,21 @@
3939
//! }
4040
//!
4141
//! impl Service for PingService {
42-
//! type Req = PingRequest;
43-
//! type Res = PingResponse;
42+
//! type Req = PingRequest;
43+
//! type Res = PingResponse;
4444
//! }
4545
//!
4646
//! // Define interaction patterns for each request type
4747
//! impl RpcMsg<PingService> for Ping {
48-
//! type Response = Pong;
48+
//! type Response = Pong;
4949
//! }
5050
//!
5151
//! // create a transport channel, here a memory channel for testing
5252
//! let (server, client) = quic_rpc::transport::flume::channel(1);
5353
//!
5454
//! // client side
5555
//! // create the rpc client given the channel and the service type
56-
//! let mut client = RpcClient::<PingService,_>::new(client);
56+
//! let mut client = RpcClient::<PingService, _>::new(client);
5757
//!
5858
//! // call the service
5959
//! let res = client.rpc(Ping).await?;
@@ -64,12 +64,12 @@
6464
//!
6565
//! let handler = Handler;
6666
//! loop {
67-
//! // accept connections
68-
//! let (msg, chan) = server.accept().await?.read_first().await?;
69-
//! // dispatch the message to the appropriate handler
70-
//! match msg {
71-
//! PingRequest::Ping(ping) => chan.rpc(ping, handler, Handler::ping).await?,
72-
//! }
67+
//! // accept connections
68+
//! let (msg, chan) = server.accept().await?.read_first().await?;
69+
//! // dispatch the message to the appropriate handler
70+
//! match msg {
71+
//! PingRequest::Ping(ping) => chan.rpc(ping, handler, Handler::ping).await?,
72+
//! }
7373
//! }
7474
//!
7575
//! // the handler. For a more complex example, this would contain any state
@@ -78,21 +78,22 @@
7878
//! struct Handler;
7979
//!
8080
//! impl Handler {
81-
//! // the handle fn for a Ping request.
81+
//! // the handle fn for a Ping request.
8282
//!
83-
//! // The return type is the response type for the service.
84-
//! // Note that this must take self by value, not by reference.
85-
//! async fn ping(self, _req: Ping) -> Pong {
86-
//! Pong
87-
//! }
83+
//! // The return type is the response type for the service.
84+
//! // Note that this must take self by value, not by reference.
85+
//! async fn ping(self, _req: Ping) -> Pong {
86+
//! Pong
87+
//! }
8888
//! }
8989
//! # Ok(())
9090
//! # }
9191
//! ```
9292
#![deny(missing_docs)]
9393
#![deny(rustdoc::broken_intra_doc_links)]
94-
use serde::{de::DeserializeOwned, Serialize};
9594
use std::fmt::{Debug, Display};
95+
96+
use serde::{de::DeserializeOwned, Serialize};
9697
pub mod client;
9798
pub mod message;
9899
pub mod server;

0 commit comments

Comments
 (0)