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
48mod translation;
49
50pub mod connection;
51pub mod either;
52pub mod muxing;
53pub mod peer_record;
54pub mod signed_envelope;
55pub mod transport;
56pub mod upgrade;
57
58pub use connection::{ConnectedPoint, Endpoint};
59pub use multiaddr::Multiaddr;
60pub use multihash;
61pub use muxing::StreamMuxer;
62pub use peer_record::PeerRecord;
63pub use signed_envelope::SignedEnvelope;
64pub use translation::address_translation;
65pub use transport::Transport;
66pub use upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
67
68#[derive(Debug, thiserror::Error)]
69#[error(transparent)]
70pub struct DecodeError(quick_protobuf::Error);