libp2prs_core/
lib.rs

1// Copyright 2020 Netwarps 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//! - A [`PeerId`] is a unique global identifier for a node on the network.
26//!   Each node must have a different `PeerId`. Normally, a `PeerId` is the
27//!   hash of the public key used to negotiate encryption on the
28//!   communication channel, thereby guaranteeing that they cannot be spoofed.
29//! - The [`Transport`] trait defines how to reach a remote node or listen for
30//!   incoming remote connections. See the `transport` module.
31//! - The [`StreamMuxer`] trait is implemented on structs that hold a connection
32//!   to a remote and can subdivide this connection into multiple substreams.
33//!   See the `muxing` module.
34//! - The [`UpgradeInfo`] and [`Upgrader`] traits define how to upgrade each
35//!   individual substream to use a protocol.
36//!   See the `upgrade` module.
37
38pub mod keys_proto {
39    include!(concat!(env!("OUT_DIR"), "/keys_proto.rs"));
40}
41
42// re-export multiaddr
43pub use libp2prs_multiaddr as multiaddr;
44// re-export multihash
45pub use multihash;
46
47pub mod identity;
48mod peer_id;
49
50pub mod multistream;
51
52pub use identity::PublicKey;
53pub use peer_id::PeerId;
54
55pub mod transport;
56pub use libp2prs_multiaddr::Multiaddr;
57pub use transport::Transport;
58
59pub mod muxing;
60pub mod secure_io;
61pub mod upgrade;
62pub use upgrade::ProtocolId;
63pub mod routing;
64
65pub mod either;
66
67pub mod peerstore;
68
69// pub mod pnet;
70pub mod translation;
71
72pub mod util;
73pub use util::{ReadEx, WriteEx};