libp2p_core/lib.rs
1// Copyright 2017-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//! Transports, upgrades, multiplexing and node handling of *libp2p*.
22//!
23//! The main concepts of libp2p-core are:
24//!
25//! - The [`Transport`] trait defines how to reach a remote node or listen for
26//! incoming remote connections. See the [`transport`] module.
27//! - The [`StreamMuxer`] trait is implemented on structs that hold a connection
28//! to a remote and can subdivide this connection into multiple substreams.
29//! See the [`muxing`] module.
30//! - The [`UpgradeInfo`], [`InboundUpgrade`] and [`OutboundUpgrade`] traits
31//! define how to upgrade each individual substream to use a protocol.
32//! See the `upgrade` module.
33
34#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
35
36mod proto {
37 #![allow(unreachable_pub)]
38 include!("generated/mod.rs");
39 pub use self::{
40 envelope_proto::*, peer_record_proto::mod_PeerRecord::*, peer_record_proto::PeerRecord,
41 };
42}
43
44/// Multi-address re-export.
45pub use multiaddr;
46pub type Negotiated<T> = multistream_select::Negotiated<T>;
47
48pub mod connection;
49pub mod either;
50pub mod muxing;
51pub mod peer_record;
52pub mod signed_envelope;
53pub mod transport;
54pub mod upgrade;
55
56pub use connection::{ConnectedPoint, Endpoint};
57pub use libp2p_identity::PeerId;
58pub use multiaddr::Multiaddr;
59pub use multihash;
60pub use muxing::StreamMuxer;
61pub use peer_record::PeerRecord;
62pub use signed_envelope::SignedEnvelope;
63pub use transport::Transport;
64pub use upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
65
66#[derive(Debug, thiserror::Error)]
67#[error(transparent)]
68pub struct DecodeError(quick_protobuf::Error);