Skip to content

Commit c652164

Browse files
committed
Update IpfsBuilder
1 parent 62f4c73 commit c652164

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

rust/hermes-ipfs/src/lib.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
#![allow(unused, dead_code, deprecated)]
66

7-
use std::str::FromStr;
7+
use std::{convert::Infallible, str::FromStr};
88

99
use derive_more::{Display, From, Into};
1010
use futures::{pin_mut, stream::BoxStream, Stream, StreamExt};
@@ -31,17 +31,18 @@ pub use rust_ipfs::Multiaddr;
3131
pub use rust_ipfs::PeerId;
3232
use rust_ipfs::{
3333
builder::UninitializedIpfs, dag::ResolveError, dummy, gossipsub::IntoGossipsubTopic,
34-
unixfs::AddOpt, GossipsubMessage, PubsubEvent, Quorum, ToRecordKey,
34+
unixfs::AddOpt, GossipsubMessage, NetworkBehaviour, PubsubEvent, Quorum, ToRecordKey,
3535
};
3636

3737
#[derive(Debug, Display, From, Into)]
3838
/// `PubSub` Message ID.
3939
pub struct MessageId(pub PubsubMessageId);
4040

4141
/// Builder type for IPFS Node configuration.
42-
pub struct IpfsBuilder(UninitializedIpfs<dummy::Behaviour>);
42+
pub struct IpfsBuilder<N>(UninitializedIpfs<N>)
43+
where N: NetworkBehaviour<ToSwarm = Infallible> + Send + Sync;
4344

44-
impl IpfsBuilder {
45+
impl<N> IpfsBuilder<N> where N: NetworkBehaviour<ToSwarm = Infallible> + Send + Sync {
4546
#[must_use]
4647
/// Create a new` IpfsBuilder`.
4748
pub fn new() -> Self {
@@ -103,12 +104,6 @@ impl IpfsBuilder {
103104
}
104105
}
105106

106-
impl Default for IpfsBuilder {
107-
fn default() -> Self {
108-
Self::new()
109-
}
110-
}
111-
112107
/// Hermes IPFS Node.
113108
pub struct HermesIpfs {
114109
/// IPFS node
@@ -126,7 +121,7 @@ impl HermesIpfs {
126121
///
127122
/// Returns an error if the IPFS daemon fails to start.
128123
pub async fn start() -> anyhow::Result<Self> {
129-
let node: Ipfs = IpfsBuilder::new()
124+
let node: Ipfs = IpfsBuilder::<dummy::Behaviour>::new()
130125
.with_default()
131126
.set_default_listener()
132127
// TODO(saibatizoku): Re-Enable default transport config when libp2p Cert bug is fixed

0 commit comments

Comments
 (0)