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

Refresh docs #392

Merged
merged 27 commits into from
Sep 23, 2020
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dd9e325
doc: fix intra links
Sep 22, 2020
d002772
doc: stop linking to private members
Sep 22, 2020
c260924
doc: add missing Ipfs::* method docs
Sep 22, 2020
86fd2f7
doc: bitswap Stats and BitswapEvent, remove re-export of BitswapEvent
Sep 22, 2020
5415751
doc: less bitswap re-exports, document BitswapStats
Sep 22, 2020
d5b55df
refactor: remove one more re-export
Sep 22, 2020
29202ef
doc: bitswap::Block which ipfs re-exports
Sep 22, 2020
34a6cf3
doc: hide IpfsInner in docs
Sep 22, 2020
8789be2
doc: ipfsoptions
Sep 23, 2020
2caf06d
doc: ipfspath and pathroot
Sep 23, 2020
627511e
refactor: trim unused pub methods
Sep 23, 2020
da4e09b
refactor: trim and doc incomplete IpfsPathError
Sep 23, 2020
91c0bff
doc: learn about ipfs::error::TryError, document it
Sep 23, 2020
c12e041
fix: remove unused import
Sep 23, 2020
7f1e276
refactor: doc and trim IpfsPath
Sep 23, 2020
639cbee
doc: refmt, cleanup comments, reorder TODO
Sep 23, 2020
53b81ba
doc: suggestions from code review
koivunej Sep 23, 2020
212f288
doc: fix invalid syntax for module doc
Sep 23, 2020
81be82c
doc: rest of top level modules
Sep 23, 2020
06e2415
doc: add usecase for ipfspath
Sep 23, 2020
b0ffa47
doc: refresh repo docs, add links
Sep 23, 2020
0eb5294
doc: add crate level docs
Sep 23, 2020
f15a9cf
doc: refresh http/README.md
Sep 23, 2020
2c16ad7
doc: add http/README.md vision stmt
Sep 23, 2020
ae29c0a
doc: top level docs for http as well
Sep 23, 2020
9286622
doc: fix link
Sep 23, 2020
4a5b564
doc: suggestions from code review
koivunej Sep 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bitswap/src/behaviour.rs
Original file line number Diff line number Diff line change
@@ -26,13 +26,15 @@ use std::{
},
};

/// Event used to communicate with the swarm or the higher level behaviour.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum BitswapEvent {
ReceivedBlock(PeerId, Block),
ReceivedWant(PeerId, Cid, Priority),
ReceivedCancel(PeerId, Cid),
}

/// Bitswap statistics.
#[derive(Debug, Default)]
pub struct Stats {
pub sent_blocks: AtomicU64,
7 changes: 7 additions & 0 deletions bitswap/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
use cid::Cid;

/// An Ipfs block consisting of a [`Cid`] and the bytes of the block.
///
/// Note: At the moment the equality is based on [`Cid`] equality, which is based on the triple
/// `(cid::Version, cid::Codec, multihash)`.
#[derive(Clone, Debug)]
pub struct Block {
/// The content identifier for this block
pub cid: Cid,
/// The data of this block
pub data: Box<[u8]>,
}

@@ -11,6 +17,7 @@ impl PartialEq for Block {
self.cid.hash() == other.cid.hash()
}
}

impl Eq for Block {}

impl Block {
10 changes: 7 additions & 3 deletions http/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# ipfs-http crate

HTTP api on top of ipfs crate. The end binary has some rudimentary ipfs CLI
HTTP api on top of `ipfs` crate. The end binary has some rudimentary ipfs CLI
functionality but mostly in the aim of testing the `rust-ipfs` via:

* [ipfs-rust-conformance](https://github.com/rs-ipfs/ipfs-rust-conformance)
* [conformance](../conformance)
* [interop](https://github.com/rs-ipfs/interop/)

The vision for this crate is to eventually provide warp filters and async
methods suitable to providing the Ipfs HTTP API in other applications as well
instead of having to write application specific debug and introspection APIs.

HTTP specs:

* https://docs.ipfs.io/reference/api/http/
* https://docs.ipfs.io/reference/http/api/

Status: Pre-alpha, most of the functionality is missing or `501 Not
Implemented`. See the repository level README for more information.
2 changes: 1 addition & 1 deletion http/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! go-ipfs compatible configuration file handling or at least setup.
//! go-ipfs compatible configuration file handling and setup.

use parity_multiaddr::Multiaddr;
use serde::{Deserialize, Serialize};
5 changes: 5 additions & 0 deletions http/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! `ipfs-http` http API implementation.
//!
//! This crate is most useful as a binary used first and foremost for compatibility testing against
//! other ipfs implementations.

#[macro_use]
extern crate tracing;

4 changes: 4 additions & 0 deletions http/src/v0.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Implementation of `/api/v0` HTTP endpoints.
//!
//! See https://docs.ipfs.io/reference/http/api/ for more information.

use ipfs::{Ipfs, IpfsTypes};
use warp::{query, Filter};

4 changes: 3 additions & 1 deletion src/dag.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! `ipfs.dag` interface implementation around [`Ipfs`].

use crate::error::Error;
use crate::ipld::{decode_ipld, encode_ipld, Ipld};
use crate::path::{IpfsPath, SlashedPath};
@@ -854,7 +856,7 @@ mod tests {
// FIXME: validate that go-ipfs still does this
let equiv_paths = vec![
prefix.sub_path("0/0").unwrap(),
prefix.into_sub_path("0/./0").unwrap(),
prefix.sub_path("0/./0").unwrap(),
];

for p in equiv_paths {
14 changes: 14 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
//! Crate-wide errors.
//!
//! The error handling in `ipfs` is subject to change in the future.

/// Just re-export anyhow for now.
///
/// # Stability
///
/// Very likely to change in the future.
pub use anyhow::Error;

/// A try conversion failed.
///
/// # Stability
///
/// Very likely to change in the future.
pub struct TryError;
2 changes: 2 additions & 0 deletions src/ipld/ipld_macro.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// Easy to use nested [`crate::ipld::Ipld`] creation with syntax similar to
/// [`serde_json::json`](https://docs.rs/serde_json/1.0/serde_json/macro.json.html) macro.
#[macro_export(local_inner_macros)]
macro_rules! make_ipld {
// Hide distracting implementation details from the generated rustdoc.
10 changes: 6 additions & 4 deletions src/ipld/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// This code was adapted from https://github.com/ipfs-rust/rust-ipld, and most of
// its code is the same as at revision b2286c53c13f3eeec2a3766387f2926838e8e4c9;
// it used to be a direct dependency, but recent updates to cid and multihash crates
// made it incompatible with them.
//! IPLD dag-json, dag-cbor and some dag-pb functionality.
//!
//! This code was adapted from https://github.com/ipfs-rust/rust-ipld, and most of
//! its code is the same as at revision b2286c53c13f3eeec2a3766387f2926838e8e4c9;
//! it used to be a direct dependency, but recent updates to cid and multihash crates
//! made it incompatible with them.

pub mod dag_cbor;
pub mod dag_json;
3 changes: 3 additions & 0 deletions src/ipns/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
//! IPNS functionality around [`Ipfs`].

use crate::error::Error;
use crate::path::{IpfsPath, PathRoot};
use crate::repo::RepoTypes;
use crate::Ipfs;

mod dnslink;

/// IPNS facade around [`Ipns`].
#[derive(Clone, Debug)]
pub struct Ipns<Types: RepoTypes> {
ipfs: Ipfs<Types>,
Loading