Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit 2a875da

Browse files
Merge #409
409: Improve documentation of public methods r=niklaslong a=niklaslong This PR goes some way towards improving the documentation of public methods as discussed in #197. Co-authored-by: Niklas Long <niklas@equilibrium.co>
2 parents bac542a + 2cf4e58 commit 2a875da

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

src/p2p/addr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ impl FromStr for MultiaddrWithoutPeerId {
8282
/// don't support it being contained within the `Multiaddr`.
8383
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8484
pub struct MultiaddrWithPeerId {
85+
/// The [`Multiaddr`] without the [`Protocol::P2p`] suffix.
8586
pub multiaddr: MultiaddrWithoutPeerId,
87+
/// The peer id from the [`Protocol::P2p`] suffix.
8688
pub peer_id: PeerId,
8789
}
8890

src/p2p/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ mod transport;
1717
pub use addr::{MultiaddrWithPeerId, MultiaddrWithoutPeerId};
1818
pub use {behaviour::KadResult, swarm::Connection};
1919

20+
/// Type alias for [`libp2p::Swarm`] running the [`behaviour::Behaviour`] with the given [`IpfsTypes`].
2021
pub type TSwarm<T> = Swarm<behaviour::Behaviour<T>>;
2122

23+
/// Defines the configuration for an IPFS swarm.
2224
pub struct SwarmOptions {
25+
/// The keypair for the PKI based identity of the local node.
2326
pub keypair: Keypair,
27+
/// The peer address of the local node created from the keypair.
2428
pub peer_id: PeerId,
29+
/// The peers to connect to on startup.
2530
pub bootstrap: Vec<(Multiaddr, PeerId)>,
31+
/// Enables mdns for peer discovery and announcement when true.
2632
pub mdns: bool,
33+
/// Custom Kademlia protocol name, see [`IpfsOptions::kad_protocol`].
2734
pub kad_protocol: Option<String>,
2835
}
2936

src/p2p/swarm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::time::Duration;
1515
pub struct Connection {
1616
/// The connected peer along with its address.
1717
pub addr: MultiaddrWithPeerId,
18-
/// Latest ping report on any of the connections
18+
/// Latest ping report on any of the connections.
1919
pub rtt: Option<Duration>,
2020
}
2121

src/path.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ impl FromStr for IpfsPath {
7575
}
7676

7777
impl IpfsPath {
78+
/// Creates a new [`IpfsPath`] from a [`PathRoot`].
7879
pub fn new(root: PathRoot) -> Self {
7980
IpfsPath {
8081
root,
8182
path: Default::default(),
8283
}
8384
}
8485

86+
/// Returns the [`PathRoot`] "protocol" configured for the [`IpfsPath`].
8587
pub fn root(&self) -> &PathRoot {
8688
&self.root
8789
}
@@ -99,7 +101,7 @@ impl IpfsPath {
99101
Ok(path)
100102
}
101103

102-
/// Returns an iterator over the path segments following the root
104+
/// Returns an iterator over the path segments following the root.
103105
pub fn iter(&self) -> impl Iterator<Item = &str> {
104106
self.path.iter().map(|s| s.as_str())
105107
}
@@ -259,6 +261,7 @@ impl fmt::Debug for PathRoot {
259261
}
260262

261263
impl PathRoot {
264+
/// Returns the `Some(Cid)` if the [`Cid`] based path is present or `None`.
262265
pub fn cid(&self) -> Option<&Cid> {
263266
match self {
264267
PathRoot::Ipld(cid) => Some(cid),

0 commit comments

Comments
 (0)