mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-30 18:21:33 +00:00
Fix compiling for WASM with websockets disabled (#934)
* Fix compiling for WASM with websockets disabled * Comment about usage
This commit is contained in:
16
src/lib.rs
16
src/lib.rs
@ -244,8 +244,10 @@ struct CommonTransport {
|
||||
type InnerImplementation = core::transport::OrTransport<dns::DnsConfig<tcp::TcpConfig>, websocket::WsConfig<dns::DnsConfig<tcp::TcpConfig>>>;
|
||||
#[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), not(feature = "libp2p-websocket")))]
|
||||
type InnerImplementation = dns::DnsConfig<tcp::TcpConfig>;
|
||||
#[cfg(any(target_os = "emscripten", target_os = "unknown"))]
|
||||
#[cfg(all(any(target_os = "emscripten", target_os = "unknown"), feature = "libp2p-websocket"))]
|
||||
type InnerImplementation = websocket::BrowserWsConfig;
|
||||
#[cfg(all(any(target_os = "emscripten", target_os = "unknown"), not(feature = "libp2p-websocket")))]
|
||||
type InnerImplementation = core::transport::dummy::DummyTransport;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct CommonTransportInner {
|
||||
@ -272,13 +274,23 @@ impl CommonTransport {
|
||||
|
||||
/// Initializes the `CommonTransport`.
|
||||
#[inline]
|
||||
#[cfg(any(target_os = "emscripten", target_os = "unknown"))]
|
||||
#[cfg(all(any(target_os = "emscripten", target_os = "unknown"), feature = "libp2p-websocket"))]
|
||||
pub fn new() -> CommonTransport {
|
||||
let inner = websocket::BrowserWsConfig::new();
|
||||
CommonTransport {
|
||||
inner: CommonTransportInner { inner }
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the `CommonTransport`.
|
||||
#[inline]
|
||||
#[cfg(all(any(target_os = "emscripten", target_os = "unknown"), not(feature = "libp2p-websocket")))]
|
||||
pub fn new() -> CommonTransport {
|
||||
let inner = core::transport::dummy::DummyTransport::new();
|
||||
CommonTransport {
|
||||
inner: CommonTransportInner { inner }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Transport for CommonTransport {
|
||||
|
Reference in New Issue
Block a user