Skip to content

Commit 1390954

Browse files
committed
clippy
1 parent bc159ca commit 1390954

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

examples/compression.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
/// Example how to limit blob requests by hash and node id, and to add
2-
/// throttling or limiting the maximum number of connections.
1+
/// Example how to use compression with iroh-blobs
32
///
4-
/// Limiting is done via a fn that returns an EventSender and internally
5-
/// makes liberal use of spawn to spawn background tasks.
6-
///
7-
/// This is fine, since the tasks will terminate as soon as the [BlobsProtocol]
8-
/// instance holding the [EventSender] will be dropped. But for production
9-
/// grade code you might nevertheless put the tasks into a [tokio::task::JoinSet] or
10-
/// [n0_future::FuturesUnordered].
3+
/// We create a derived protocol that compresses both requests and responses using lz4
4+
/// or any other compression algorithm supported by async-compression.
115
mod common;
126
use std::{fmt::Debug, path::PathBuf};
137

@@ -211,14 +205,14 @@ async fn main() -> Result<()> {
211205
Args::Get { ticket, target } => {
212206
let store = MemStore::new();
213207
let conn = endpoint
214-
.connect(ticket.node_addr().clone(), &lz4::Compression::ALPN)
208+
.connect(ticket.node_addr().clone(), lz4::Compression::ALPN)
215209
.await?;
216210
let connection_id = conn.stable_id() as u64;
217211
let (send, recv) = conn.open_bi().await?;
218212
let send = compression.send_stream(send);
219213
let recv = compression.recv_stream(recv);
220214
let sp = StreamPair::new(connection_id, recv, send);
221-
let stats = store.remote().fetch(sp, ticket.hash_and_format()).await?;
215+
let _stats = store.remote().fetch(sp, ticket.hash_and_format()).await?;
222216
if let Some(target) = target {
223217
let size = store.export(ticket.hash(), &target).await?;
224218
println!("Wrote {} bytes to {}", size, target.display());

src/api/remote.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl Remote {
501501

502502
pub fn fetch(
503503
&self,
504-
sp: impl GetStreamPair + Send + 'static,
504+
sp: impl GetStreamPair + 'static,
505505
content: impl Into<HashAndFormat>,
506506
) -> GetProgress {
507507
let content = content.into();
@@ -851,12 +851,8 @@ pub trait GetStreamPair: Send + 'static {
851851
) -> impl Future<Output = io::Result<StreamPair<impl RecvStream, impl SendStream>>> + Send + 'static;
852852
}
853853

854-
impl<R: RecvStream + 'static, W: SendStream + 'static> GetStreamPair
855-
for StreamPair<R, W>
856-
{
857-
async fn open_stream_pair(
858-
self,
859-
) -> io::Result<StreamPair<impl RecvStream, impl SendStream>> {
854+
impl<R: RecvStream + 'static, W: SendStream + 'static> GetStreamPair for StreamPair<R, W> {
855+
async fn open_stream_pair(self) -> io::Result<StreamPair<impl RecvStream, impl SendStream>> {
860856
Ok(self)
861857
}
862858
}

src/provider.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::{
3434
ClientConnected, ClientResult, ConnectionClosed, HasErrorCode, ProgressError,
3535
RequestTracker,
3636
},
37-
util::{RecvStream, SendStream, SendStreamExt, RecvStreamExt},
37+
util::{RecvStream, RecvStreamExt, SendStream, SendStreamExt},
3838
Hash,
3939
};
4040
pub mod events;
@@ -332,12 +332,7 @@ pub trait ErrorHandler {
332332
fn reset(writer: &mut Self::W, code: VarInt) -> impl Future<Output = ()>;
333333
}
334334

335-
async fn handle_read_request_result<
336-
R: RecvStream,
337-
W: SendStream,
338-
T,
339-
E: HasErrorCode,
340-
>(
335+
async fn handle_read_request_result<R: RecvStream, W: SendStream, T, E: HasErrorCode>(
341336
pair: &mut StreamPair<R, W>,
342337
r: Result<T, E>,
343338
) -> Result<T, E> {

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub use stream::{
77
AsyncReadRecvStream, AsyncWriteSendStream, RecvStream, RecvStreamAsyncStreamReader,
88
RecvStreamSpecific, SendStream, SendStreamSpecific,
99
};
10-
pub(crate) use stream::{SendStreamExt, RecvStreamExt};
10+
pub(crate) use stream::{RecvStreamExt, SendStreamExt};
1111

1212
pub(crate) mod serde {
1313
// Module that handles io::Error serialization/deserialization

0 commit comments

Comments
 (0)