libp2p/
lib.rs

1// Copyright 2018 Parity Technologies (UK) Ltd.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a
4// copy of this software and associated documentation files (the "Software"),
5// to deal in the Software without restriction, including without limitation
6// the rights to use, copy, modify, merge, publish, distribute, sublicense,
7// and/or sell copies of the Software, and to permit persons to whom the
8// Software is furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19// DEALINGS IN THE SOFTWARE.
20
21//! libp2p is a modular peer-to-peer networking framework.
22//!
23//! To learn more about the general libp2p multi-language framework visit <https://libp2p.io>.
24//!
25//! To get started with this libp2p implementation in Rust, please take a look
26//! at the [`tutorials`]. Further examples can be found in the
27//! [examples] directory.
28//!
29//! [examples]: https://github.com/libp2p/rust-libp2p/tree/master/examples
30
31#![doc(html_logo_url = "https://libp2p.io/img/logo_small.png")]
32#![doc(html_favicon_url = "https://libp2p.io/img/favicon.png")]
33#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
34
35pub use bytes;
36pub use futures;
37#[doc(inline)]
38pub use libp2p_allow_block_list as allow_block_list;
39#[cfg(feature = "autonat")]
40#[doc(inline)]
41pub use libp2p_autonat as autonat;
42#[doc(inline)]
43pub use libp2p_connection_limits as connection_limits;
44#[doc(inline)]
45pub use libp2p_core as core;
46#[doc(inline)]
47pub use libp2p_core::multihash;
48#[cfg(feature = "dcutr")]
49#[doc(inline)]
50pub use libp2p_dcutr as dcutr;
51#[cfg(feature = "dns")]
52#[cfg_attr(docsrs, doc(cfg(feature = "dns")))]
53#[cfg(not(target_arch = "wasm32"))]
54#[doc(inline)]
55pub use libp2p_dns as dns;
56#[cfg(feature = "floodsub")]
57#[doc(inline)]
58pub use libp2p_floodsub as floodsub;
59#[cfg(feature = "gossipsub")]
60#[doc(inline)]
61pub use libp2p_gossipsub as gossipsub;
62#[cfg(feature = "identify")]
63#[doc(inline)]
64pub use libp2p_identify as identify;
65#[cfg(feature = "kad")]
66#[doc(inline)]
67pub use libp2p_kad as kad;
68#[cfg(feature = "mdns")]
69#[cfg(not(target_arch = "wasm32"))]
70#[cfg_attr(docsrs, doc(cfg(feature = "mdns")))]
71#[doc(inline)]
72pub use libp2p_mdns as mdns;
73#[cfg(feature = "memory-connection-limits")]
74#[cfg(not(target_arch = "wasm32"))]
75#[cfg_attr(docsrs, doc(cfg(feature = "memory-connection-limits")))]
76#[doc(inline)]
77pub use libp2p_memory_connection_limits as memory_connection_limits;
78#[cfg(feature = "metrics")]
79#[doc(inline)]
80pub use libp2p_metrics as metrics;
81#[cfg(feature = "noise")]
82#[doc(inline)]
83pub use libp2p_noise as noise;
84#[cfg(feature = "ping")]
85#[doc(inline)]
86pub use libp2p_ping as ping;
87#[cfg(feature = "plaintext")]
88#[doc(inline)]
89pub use libp2p_plaintext as plaintext;
90#[cfg(feature = "pnet")]
91#[doc(inline)]
92pub use libp2p_pnet as pnet;
93#[cfg(feature = "quic")]
94#[cfg(not(target_arch = "wasm32"))]
95pub use libp2p_quic as quic;
96#[cfg(feature = "relay")]
97#[doc(inline)]
98pub use libp2p_relay as relay;
99#[cfg(feature = "rendezvous")]
100#[doc(inline)]
101pub use libp2p_rendezvous as rendezvous;
102#[cfg(feature = "request-response")]
103#[doc(inline)]
104pub use libp2p_request_response as request_response;
105#[doc(inline)]
106pub use libp2p_swarm as swarm;
107#[cfg(feature = "tcp")]
108#[cfg(not(target_arch = "wasm32"))]
109#[cfg_attr(docsrs, doc(cfg(feature = "tcp")))]
110#[doc(inline)]
111pub use libp2p_tcp as tcp;
112#[cfg(feature = "tls")]
113#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
114#[cfg(not(target_arch = "wasm32"))]
115#[doc(inline)]
116pub use libp2p_tls as tls;
117#[cfg(feature = "uds")]
118#[cfg_attr(docsrs, doc(cfg(feature = "uds")))]
119#[cfg(not(target_arch = "wasm32"))]
120#[doc(inline)]
121pub use libp2p_uds as uds;
122#[cfg(feature = "upnp")]
123#[cfg(not(target_arch = "wasm32"))]
124#[doc(inline)]
125pub use libp2p_upnp as upnp;
126#[cfg(feature = "webrtc-websys")]
127#[doc(inline)]
128pub use libp2p_webrtc_websys as webrtc_websys;
129#[cfg(feature = "websocket")]
130#[cfg(not(target_arch = "wasm32"))]
131#[doc(inline)]
132pub use libp2p_websocket as websocket;
133#[cfg(feature = "websocket-websys")]
134#[doc(inline)]
135pub use libp2p_websocket_websys as websocket_websys;
136#[cfg(feature = "webtransport-websys")]
137#[cfg_attr(docsrs, doc(cfg(feature = "webtransport-websys")))]
138#[doc(inline)]
139pub use libp2p_webtransport_websys as webtransport_websys;
140#[cfg(feature = "yamux")]
141#[doc(inline)]
142pub use libp2p_yamux as yamux;
143#[doc(inline)]
144pub use multiaddr;
145
146mod builder;
147mod transport_ext;
148
149pub mod bandwidth;
150
151#[cfg(doc)]
152pub mod tutorials;
153
154#[cfg(all(not(target_arch = "wasm32"), feature = "websocket"))]
155pub use builder::WebsocketError as WebsocketBuilderError;
156pub use libp2p_identity as identity;
157pub use libp2p_identity::PeerId;
158pub use libp2p_swarm::{Stream, StreamProtocol};
159
160pub use self::{
161    builder::{
162        BehaviourError as BehaviourBuilderError, SwarmBuilder,
163        TransportError as TransportBuilderError,
164    },
165    core::{
166        transport::TransportError,
167        upgrade::{InboundUpgrade, OutboundUpgrade},
168        Transport,
169    },
170    multiaddr::{multiaddr as build_multiaddr, Multiaddr},
171    swarm::Swarm,
172    transport_ext::TransportExt,
173};