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_core::multihash;
39#[doc(inline)]
40pub use multiaddr;
41
42#[doc(inline)]
43pub use libp2p_allow_block_list as allow_block_list;
44#[cfg(feature = "autonat")]
45#[doc(inline)]
46pub use libp2p_autonat as autonat;
47#[doc(inline)]
48pub use libp2p_connection_limits as connection_limits;
49#[doc(inline)]
50pub use libp2p_core as core;
51#[cfg(feature = "dcutr")]
52#[doc(inline)]
53pub use libp2p_dcutr as dcutr;
54#[cfg(feature = "dns")]
55#[cfg_attr(docsrs, doc(cfg(feature = "dns")))]
56#[cfg(not(target_arch = "wasm32"))]
57#[doc(inline)]
58pub use libp2p_dns as dns;
59#[cfg(feature = "floodsub")]
60#[doc(inline)]
61pub use libp2p_floodsub as floodsub;
62#[cfg(feature = "gossipsub")]
63#[doc(inline)]
64pub use libp2p_gossipsub as gossipsub;
65#[cfg(feature = "identify")]
66#[doc(inline)]
67pub use libp2p_identify as identify;
68#[cfg(feature = "kad")]
69#[doc(inline)]
70pub use libp2p_kad as kad;
71#[cfg(feature = "mdns")]
72#[cfg(not(target_arch = "wasm32"))]
73#[cfg_attr(docsrs, doc(cfg(feature = "mdns")))]
74#[doc(inline)]
75pub use libp2p_mdns as mdns;
76#[cfg(feature = "memory-connection-limits")]
77#[cfg(not(target_arch = "wasm32"))]
78#[cfg_attr(docsrs, doc(cfg(feature = "memory-connection-limits")))]
79#[doc(inline)]
80pub use libp2p_memory_connection_limits as memory_connection_limits;
81#[cfg(feature = "metrics")]
82#[doc(inline)]
83pub use libp2p_metrics as metrics;
84#[cfg(feature = "noise")]
85#[doc(inline)]
86pub use libp2p_noise as noise;
87#[cfg(feature = "ping")]
88#[doc(inline)]
89pub use libp2p_ping as ping;
90#[cfg(feature = "plaintext")]
91#[doc(inline)]
92pub use libp2p_plaintext as plaintext;
93#[cfg(feature = "pnet")]
94#[doc(inline)]
95pub use libp2p_pnet as pnet;
96#[cfg(feature = "quic")]
97#[cfg(not(target_arch = "wasm32"))]
98pub use libp2p_quic as quic;
99#[cfg(feature = "relay")]
100#[doc(inline)]
101pub use libp2p_relay as relay;
102#[cfg(feature = "rendezvous")]
103#[doc(inline)]
104pub use libp2p_rendezvous as rendezvous;
105#[cfg(feature = "request-response")]
106#[doc(inline)]
107pub use libp2p_request_response as request_response;
108#[doc(inline)]
109pub use libp2p_swarm as swarm;
110#[cfg(feature = "tcp")]
111#[cfg(not(target_arch = "wasm32"))]
112#[cfg_attr(docsrs, doc(cfg(feature = "tcp")))]
113#[doc(inline)]
114pub use libp2p_tcp as tcp;
115#[cfg(feature = "tls")]
116#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
117#[cfg(not(target_arch = "wasm32"))]
118#[doc(inline)]
119pub use libp2p_tls as tls;
120#[cfg(feature = "uds")]
121#[cfg_attr(docsrs, doc(cfg(feature = "uds")))]
122#[cfg(not(target_arch = "wasm32"))]
123#[doc(inline)]
124pub use libp2p_uds as uds;
125#[cfg(feature = "upnp")]
126#[cfg(not(target_arch = "wasm32"))]
127#[doc(inline)]
128pub use libp2p_upnp as upnp;
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
144mod builder;
145mod transport_ext;
146
147pub mod bandwidth;
148
149#[cfg(doc)]
150pub mod tutorials;
151
152pub use self::builder::SwarmBuilder;
153pub use self::core::{
154    transport::TransportError,
155    upgrade::{InboundUpgrade, OutboundUpgrade},
156    Transport,
157};
158pub use self::multiaddr::{multiaddr as build_multiaddr, Multiaddr};
159pub use self::swarm::Swarm;
160pub use self::transport_ext::TransportExt;
161pub use libp2p_identity as identity;
162pub use libp2p_identity::PeerId;
163pub use libp2p_swarm::{Stream, StreamProtocol};