Skip to content

Commit 68967f9

Browse files
committed
Add fn boxed to client...
...so there is an easy way to get rid of the annoying type parameter
1 parent 31dc5c5 commit 68967f9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/rpc/client/blobs.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ use iroh::NodeAddr;
7474
use portable_atomic::{AtomicU64, Ordering};
7575
use quic_rpc::{
7676
client::{BoxStreamSync, BoxedConnector},
77+
transport::boxed::BoxableConnector,
7778
Connector, RpcClient,
7879
};
7980
use serde::{Deserialize, Serialize};
@@ -87,7 +88,7 @@ use crate::{
8788
format::collection::{Collection, SimpleStore},
8889
get::db::DownloadProgress as BytesDownloadProgress,
8990
net_protocol::BlobDownloadRequest,
90-
rpc::proto::RpcService,
91+
rpc::proto::{Request, Response, RpcService},
9192
store::{BaoBlobSize, ConsistencyCheckProgress, ExportFormat, ExportMode, ValidateProgress},
9293
util::SetTagOption,
9394
BlobFormat, Hash, Tag,
@@ -108,7 +109,7 @@ use crate::rpc::proto::blobs::{
108109
#[derive(Debug, Clone)]
109110
#[repr(transparent)]
110111
pub struct Client<C = BoxedConnector<RpcService>> {
111-
pub(super) rpc: RpcClient<RpcService, C>,
112+
pub(crate) rpc: RpcClient<RpcService, C>,
112113
}
113114

114115
/// Type alias for a memory-backed client.
@@ -123,6 +124,14 @@ where
123124
Self { rpc }
124125
}
125126

127+
/// Box the client to avoid having to provide the connector type.
128+
pub fn boxed(&self) -> Client<BoxedConnector<RpcService>>
129+
where
130+
C: BoxableConnector<Response, Request>,
131+
{
132+
Client::new(self.rpc.clone().boxed())
133+
}
134+
126135
/// Get a tags client.
127136
pub fn tags(&self) -> tags::Client<C> {
128137
tags::Client::new(self.rpc.clone())

0 commit comments

Comments
 (0)