Skip to content
Closed
180 changes: 170 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ serde = ["libp2p-core/serde", "libp2p-kad?/serde", "libp2p-gossipsub?/serde"]
tcp = ["dep:libp2p-tcp"]
tls = ["dep:libp2p-tls"]
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-upnp?/tokio"]
smol = ["libp2p-swarm/smol", "libp2p-tcp?/smol", "libp2p-quic?/smol"]
uds = ["dep:libp2p-uds"]
wasm-bindgen = ["futures-timer/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"]
webrtc-websys = ['dep:libp2p-webrtc-websys']
Expand Down
16 changes: 16 additions & 0 deletions libp2p/src/builder/phase/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ pub enum NoProviderSpecified {}
/// Represents the Tokio runtime environment.
pub enum Tokio {}

#[cfg(all(not(target_arch = "wasm32"), feature = "smol"))]
/// Represents the Smol runtime environment.
pub enum Smol {}

#[cfg(feature = "wasm-bindgen")]
/// Represents the WasmBindgen environment for WebAssembly.
pub enum WasmBindgen {}
Expand All @@ -35,6 +39,18 @@ impl SwarmBuilder<NoProviderSpecified, ProviderPhase> {
}
}

/// Configures the SwarmBuilder to use the Smol runtime.
/// This method is only available when compiling for non-Wasm
/// targets with the `smol` feature enabled.
#[cfg(all(not(target_arch = "wasm32"), feature = "smol"))]
pub fn with_smol(self) -> SwarmBuilder<Smol, TcpPhase> {
SwarmBuilder {
keypair: self.keypair,
phantom: PhantomData,
phase: TcpPhase {},
}
}

/// Configures the SwarmBuilder for WebAssembly using WasmBindgen.
/// This method is available when the `wasm-bindgen` feature is enabled.
#[cfg(feature = "wasm-bindgen")]
Expand Down
Loading
Loading