mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-02 11:11:36 +00:00
Test on wasm32-unknown-unknown (#806)
* Test on wasm32-unknown-unknown * Fix compilation
This commit is contained in:
18
src/lib.rs
18
src/lib.rs
@ -75,7 +75,7 @@
|
||||
//! Example:
|
||||
//!
|
||||
//! ```rust
|
||||
//! # #[cfg(all(not(target_os = "emscripten"), feature = "libp2p-secio"))] {
|
||||
//! # #[cfg(all(any(target_os = "emscripten", target_os = "unknown"), feature = "libp2p-secio"))] {
|
||||
//! use libp2p::{Transport, tcp::TcpConfig, secio::{SecioConfig, SecioKeyPair}};
|
||||
//! let tcp = TcpConfig::new();
|
||||
//! let secio_upgrade = SecioConfig::new(SecioKeyPair::ed25519_generated().unwrap());
|
||||
@ -140,19 +140,19 @@ extern crate libp2p_core_derive;
|
||||
extern crate tokio_executor;
|
||||
|
||||
pub extern crate libp2p_core as core;
|
||||
#[cfg(not(target_os = "emscripten"))]
|
||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
||||
pub extern crate libp2p_dns as dns;
|
||||
pub extern crate libp2p_identify as identify;
|
||||
pub extern crate libp2p_kad as kad;
|
||||
pub extern crate libp2p_floodsub as floodsub;
|
||||
pub extern crate libp2p_mplex as mplex;
|
||||
#[cfg(not(target_os = "emscripten"))]
|
||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
||||
pub extern crate libp2p_mdns as mdns;
|
||||
pub extern crate libp2p_ping as ping;
|
||||
pub extern crate libp2p_plaintext as plaintext;
|
||||
pub extern crate libp2p_ratelimit as ratelimit;
|
||||
pub extern crate libp2p_secio as secio;
|
||||
#[cfg(not(target_os = "emscripten"))]
|
||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
||||
pub extern crate libp2p_tcp as tcp;
|
||||
pub extern crate libp2p_uds as uds;
|
||||
#[cfg(feature = "libp2p-websocket")]
|
||||
@ -222,11 +222,11 @@ struct CommonTransport {
|
||||
inner: CommonTransportInner
|
||||
}
|
||||
|
||||
#[cfg(all(not(target_os = "emscripten"), feature = "libp2p-websocket"))]
|
||||
#[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), feature = "libp2p-websocket"))]
|
||||
type InnerImplementation = core::transport::OrTransport<dns::DnsConfig<tcp::TcpConfig>, websocket::WsConfig<dns::DnsConfig<tcp::TcpConfig>>>;
|
||||
#[cfg(all(not(target_os = "emscripten"), not(feature = "libp2p-websocket")))]
|
||||
#[cfg(all(not(any(target_os = "emscripten", target_os = "unknown")), not(feature = "libp2p-websocket")))]
|
||||
type InnerImplementation = dns::DnsConfig<tcp::TcpConfig>;
|
||||
#[cfg(target_os = "emscripten")]
|
||||
#[cfg(any(target_os = "emscripten", target_os = "unknown"))]
|
||||
type InnerImplementation = websocket::BrowserWsConfig;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@ -237,7 +237,7 @@ struct CommonTransportInner {
|
||||
impl CommonTransport {
|
||||
/// Initializes the `CommonTransport`.
|
||||
#[inline]
|
||||
#[cfg(not(target_os = "emscripten"))]
|
||||
#[cfg(not(any(target_os = "emscripten", target_os = "unknown")))]
|
||||
pub fn new() -> CommonTransport {
|
||||
let transport = tcp::TcpConfig::new();
|
||||
let transport = dns::DnsConfig::new(transport);
|
||||
@ -254,7 +254,7 @@ impl CommonTransport {
|
||||
|
||||
/// Initializes the `CommonTransport`.
|
||||
#[inline]
|
||||
#[cfg(target_os = "emscripten")]
|
||||
#[cfg(any(target_os = "emscripten", target_os = "unknown"))]
|
||||
pub fn new() -> CommonTransport {
|
||||
let inner = websocket::BrowserWsConfig::new();
|
||||
CommonTransport {
|
||||
|
Reference in New Issue
Block a user