Skip to content

Commit 47f8c51

Browse files
committed
cargo fmt
1 parent b083fe3 commit 47f8c51

36 files changed

+643
-636
lines changed

lafere-api-codegen/src/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
use crate::ApiArgs;
12
use crate::util::{
23
lafere_api_crate, ref_type, validate_inputs, validate_signature,
34
};
4-
use crate::ApiArgs;
55

66
use proc_macro2::TokenStream;
77
use quote::{format_ident, quote};

lafere-api-codegen/src/args.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ use syn::parse::{Parse, ParseStream, Result};
22

33
use syn::Type;
44

5-
65
#[derive(Clone)]
76
pub(crate) struct ApiArgs {
8-
pub ty: Type
7+
pub ty: Type,
98
}
109

1110
impl Parse for ApiArgs {
@@ -14,4 +13,4 @@ impl Parse for ApiArgs {
1413

1514
Ok(Self { ty })
1615
}
17-
}
16+
}

lafere-api-codegen/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
mod args;
1+
mod action;
22
mod api;
3+
mod args;
34
mod message;
4-
mod action;
55
mod util;
66

77
use args::ApiArgs;
88

99
use proc_macro::TokenStream;
10-
use syn::{parse_macro_input, ItemFn, DeriveInput};
10+
use syn::{DeriveInput, ItemFn, parse_macro_input};
1111

1212
/*
1313
#[api(Request)]
@@ -28,7 +28,6 @@ pub fn api(attrs: TokenStream, item: TokenStream) -> TokenStream {
2828
.into()
2929
}
3030

31-
3231
/*
3332
#[derive(IntoMessage)]
3433
#[message(json)]
@@ -58,4 +57,4 @@ pub fn derive_action(input: TokenStream) -> TokenStream {
5857
action::expand(input)
5958
.unwrap_or_else(|e| e.to_compile_error())
6059
.into()
61-
}
60+
}

lafere-api-codegen/src/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::util::lafere_api_crate;
22

33
use proc_macro2::{Span, TokenStream};
4-
use quote::{quote, ToTokens};
4+
use quote::{ToTokens, quote};
55
use syn::{
66
Attribute, DeriveInput, Error, Generics, Ident, TypeGenerics, WhereClause,
77
};

lafere-api-codegen/src/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use proc_macro2::{Ident, Span, TokenStream};
22
use quote::quote;
3-
use syn::{punctuated, Error, FnArg, Result, Signature, Type, TypeReference};
3+
use syn::{Error, FnArg, Result, Signature, Type, TypeReference, punctuated};
44

5-
use proc_macro_crate::{crate_name, FoundCrate};
5+
use proc_macro_crate::{FoundCrate, crate_name};
66

77
pub(crate) fn validate_signature(sig: &Signature) -> Result<()> {
88
if let Some(con) = &sig.constness {
@@ -45,7 +45,7 @@ pub(crate) fn validate_inputs(
4545
for fn_arg in inputs {
4646
let ty = match fn_arg {
4747
FnArg::Receiver(r) => {
48-
return Err(Error::new_spanned(r, "self not allowed"))
48+
return Err(Error::new_spanned(r, "self not allowed"));
4949
}
5050
FnArg::Typed(t) => t.ty.clone(),
5151
};

lafere-api/src/encdec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub mod json {
55
use crate::message::{Action, Message, PacketBytes};
66
use bytes::BytesRead;
77

8-
use serde::{de::DeserializeOwned, Serialize};
8+
use serde::{Serialize, de::DeserializeOwned};
99

1010
pub fn encode<T, A, B>(value: T) -> Result<Message<A, B>, MessageError>
1111
where

lafere-api/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ mod json_tests {
439439
use crate::error;
440440
use crate::message;
441441
use crate::request::Request;
442-
use codegen::{api, FromMessage, IntoMessage};
442+
use codegen::{FromMessage, IntoMessage, api};
443443

444444
use std::fmt;
445445

lafere-api/tests/advanced.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ mod api {
1616
use serde::{Deserialize, Serialize};
1717

1818
use lafere_api::{
19+
Action, FromMessage, IntoMessage,
1920
error::{ApiError, MessageError, RequestError},
2021
message::{FromMessage, IntoMessage, Message, PacketBytes},
2122
request::Request,
22-
Action, FromMessage, IntoMessage,
2323
};
2424

2525
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Action)]

lafere-api/tests/complete.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ mod api {
1616
use serde::{Deserialize, Serialize};
1717

1818
use lafere_api::{
19+
Action, FromMessage, IntoMessage,
1920
error::{ApiError, MessageError, RequestError},
2021
request::Request,
21-
Action, FromMessage, IntoMessage,
2222
};
2323

2424
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Action)]

lafere/src/client.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1-
use crate::plain;
2-
use crate::error::{TaskError, RequestError};
1+
use crate::error::{RequestError, TaskError};
32
use crate::handler::{
4-
TaskHandle, client::Sender, StreamSender, StreamReceiver, Configurator
3+
Configurator, StreamReceiver, StreamSender, TaskHandle, client::Sender,
54
};
65
use crate::packet::{Packet, PlainBytes};
7-
use crate::util::{PinnedFuture, ByteStream};
6+
use crate::plain;
7+
use crate::util::{ByteStream, PinnedFuture};
88

99
#[cfg(feature = "encrypted")]
1010
use crate::{encrypted, packet::EncryptedBytes};
1111
#[cfg(feature = "encrypted")]
1212
use crypto::signature as sign;
1313

14-
use std::time::Duration;
1514
use std::io;
16-
15+
use std::time::Duration;
1716

1817
#[derive(Debug, Clone)]
1918
pub struct Config {
2019
pub timeout: Duration,
2120
/// if the limit is 0 there is no limit
22-
pub body_limit: u32
21+
pub body_limit: u32,
2322
}
2423

2524
/// Reconnection strategy
26-
///
25+
///
2726
/// You should probably add a timeout before reconnecting
2827
pub struct ReconStrat<S> {
2928
// async fn(error_count: usize) -> io::Result<S>
30-
pub(crate) inner: Box<
31-
dyn FnMut(usize) -> PinnedFuture<'static, io::Result<S>> + Send
32-
>
29+
pub(crate) inner:
30+
Box<dyn FnMut(usize) -> PinnedFuture<'static, io::Result<S>> + Send>,
3331
}
3432

3533
impl<S> ReconStrat<S> {
@@ -38,30 +36,30 @@ impl<S> ReconStrat<S> {
3836
/// async fn new_stream(error_count: usize) -> io::Result<S>;
3937
/// ```
4038
pub fn new<F: 'static>(f: F) -> Self
41-
where F: FnMut(usize) -> PinnedFuture<'static, io::Result<S>> + Send {
42-
Self {
43-
inner: Box::new(f)
44-
}
39+
where
40+
F: FnMut(usize) -> PinnedFuture<'static, io::Result<S>> + Send,
41+
{
42+
Self { inner: Box::new(f) }
4543
}
4644
}
4745

4846
/// A connection to a server
4947
pub struct Connection<P> {
5048
sender: Sender<P>,
51-
task: TaskHandle
49+
task: TaskHandle,
5250
}
5351

5452
impl<P> Connection<P> {
5553
/// Creates a new connection to a server with an existing stream
5654
pub fn new<S>(
5755
byte_stream: S,
5856
cfg: Config,
59-
recon_strat: Option<ReconStrat<S>>
57+
recon_strat: Option<ReconStrat<S>>,
6058
) -> Self
6159
where
6260
S: ByteStream,
6361
P: Packet<PlainBytes> + Send + 'static,
64-
P::Header: Send
62+
P::Header: Send,
6563
{
6664
plain::client(byte_stream, cfg, recon_strat)
6765
}
@@ -73,12 +71,12 @@ impl<P> Connection<P> {
7371
byte_stream: S,
7472
cfg: Config,
7573
recon_strat: Option<ReconStrat<S>>,
76-
sign: sign::PublicKey
74+
sign: sign::PublicKey,
7775
) -> Self
7876
where
7977
S: ByteStream,
8078
P: Packet<EncryptedBytes> + Send + 'static,
81-
P::Header: Send
79+
P::Header: Send,
8280
{
8381
encrypted::client(byte_stream, cfg, recon_strat, sign)
8482
}
@@ -101,7 +99,7 @@ impl<P> Connection<P> {
10199

102100
/// Send a request waiting until a response is available or the connection
103101
/// closes
104-
///
102+
///
105103
/// ## Errors
106104
/// - Writing the packet failed
107105
/// - Reading the response packet failed
@@ -113,15 +111,15 @@ impl<P> Connection<P> {
113111
/// Create a new stream to send packets.
114112
pub async fn request_sender(
115113
&self,
116-
packet: P
114+
packet: P,
117115
) -> Result<StreamSender<P>, RequestError> {
118116
self.sender.request_sender(packet).await
119117
}
120118

121119
/// Opens a new stream to listen to packets.
122120
pub async fn request_receiver(
123121
&self,
124-
packet: P
122+
packet: P,
125123
) -> Result<StreamReceiver<P>, RequestError> {
126124
self.sender.request_receiver(packet).await
127125
}
@@ -141,4 +139,4 @@ impl<P> Connection<P> {
141139
pub async fn close(self) -> Result<(), TaskError> {
142140
self.task.close().await
143141
}
144-
}
142+
}

0 commit comments

Comments
 (0)