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 = "peer-store")]
85#[doc(inline)]
86pub use libp2p_peer_store as peer_store;
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(all(feature = "webrtc-websys", target_arch = "wasm32"))]
130#[doc(inline)]
131pub use libp2p_webrtc_websys as webrtc_websys;
132#[cfg(feature = "websocket")]
133#[cfg(not(target_arch = "wasm32"))]
134#[doc(inline)]
135pub use libp2p_websocket as websocket;
136#[cfg(all(feature = "websocket-websys", target_arch = "wasm32"))]
137#[doc(inline)]
138pub use libp2p_websocket_websys as websocket_websys;
139#[cfg(all(feature = "webtransport-websys", target_arch = "wasm32"))]
140#[cfg_attr(docsrs, doc(cfg(feature = "webtransport-websys")))]
141#[doc(inline)]
142pub use libp2p_webtransport_websys as webtransport_websys;
143#[cfg(feature = "yamux")]
144#[doc(inline)]
145pub use libp2p_yamux as yamux;
146#[doc(inline)]
147pub use multiaddr;
148
149mod builder;
150mod transport_ext;
151
152pub mod bandwidth;
153
154#[cfg(doc)]
155pub mod tutorials;
156
157#[cfg(all(not(target_arch = "wasm32"), feature = "websocket"))]
158pub use builder::WebsocketError as WebsocketBuilderError;
159pub use libp2p_identity as identity;
160pub use libp2p_identity::PeerId;
161pub use libp2p_swarm::{Stream, StreamProtocol};
162
163pub use self::{
164    builder::{
165        BehaviourError as BehaviourBuilderError, SwarmBuilder,
166        TransportError as TransportBuilderError,
167    },
168    core::{
169        transport::TransportError,
170        upgrade::{InboundUpgrade, OutboundUpgrade},
171        Transport,
172    },
173    multiaddr::{multiaddr as build_multiaddr, Multiaddr},
174    swarm::Swarm,
175    transport_ext::TransportExt,
176};