Skip to content

Commit 2dac46c

Browse files
committed
Use async syntax for implementing ProtocolHandler
1 parent 2d72de0 commit 2dac46c

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/net_protocol.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
//! # }
3737
//! ```
3838
39-
use std::{fmt::Debug, future::Future, ops::Deref, sync::Arc};
39+
use std::{fmt::Debug, ops::Deref, sync::Arc};
4040

4141
use iroh::{
4242
endpoint::Connection,
@@ -100,25 +100,16 @@ impl BlobsProtocol {
100100
}
101101

102102
impl ProtocolHandler for BlobsProtocol {
103-
fn accept(
104-
&self,
105-
conn: Connection,
106-
) -> impl Future<Output = std::result::Result<(), AcceptError>> + Send {
103+
async fn accept(&self, conn: Connection) -> std::result::Result<(), AcceptError> {
107104
let store = self.store().clone();
108105
let events = self.inner.events.clone();
109-
110-
Box::pin(async move {
111-
crate::provider::handle_connection(conn, store, events).await;
112-
Ok(())
113-
})
106+
crate::provider::handle_connection(conn, store, events).await;
107+
Ok(())
114108
}
115109

116-
fn shutdown(&self) -> impl Future<Output = ()> + Send {
117-
let store = self.store().clone();
118-
Box::pin(async move {
119-
if let Err(cause) = store.shutdown().await {
120-
error!("error shutting down store: {:?}", cause);
121-
}
122-
})
110+
async fn shutdown(&self) {
111+
if let Err(cause) = self.store().shutdown().await {
112+
error!("error shutting down store: {:?}", cause);
113+
}
123114
}
124115
}

0 commit comments

Comments
 (0)