Go to file
2020-03-03 13:00:21 +01:00
.github Add ci. 2020-03-03 13:00:21 +01:00
examples Run rustfmt. 2020-03-03 13:00:21 +01:00
src Fix build on windows. 2020-03-03 13:00:21 +01:00
.gitignore Initial commit. 2019-01-30 15:03:09 +01:00
build.rs Add prost! 2020-02-06 18:42:34 +01:00
Cargo.lock Fix build on windows. 2020-03-03 13:00:21 +01:00
Cargo.toml Fix build on windows. 2020-03-03 13:00:21 +01:00
LICENSE-APACHE switch license from isc to mit/apl2.0 2020-02-23 17:18:08 +01:00
LICENSE-MIT switch license from isc to mit/apl2.0 2020-02-23 17:18:08 +01:00
README.md docs: use the Rust IPFS logo 2020-02-26 17:03:28 +00:00


Rust IPFS

Build Status Back on OpenCollective Matrix Discord

Currently implements an altruistic bitswap strategy over mdns.

Getting started

use ipfs::{UninitializedIpfs, IpfsOptions, Ipld, Types};
use futures::join;
use futures::{FutureExt, TryFutureExt};

fn main() {
    let options = IpfsOptions::<Types>::default();
    env_logger::Builder::new().parse_filters(&options.ipfs_log).init();

    tokio::runtime::current_thread::block_on_all(async move {
        // Start daemon and initialize repo
        let (ipfs, fut) = UninitializedIpfs::new(options).await.start().await.unwrap();
        tokio::spawn(fut.unit_error().boxed().compat());

        // Create a DAG
        let block1: Ipld = "block1".to_string().into();
        let block2: Ipld = "block2".to_string().into();
        let f1 = ipfs.put_dag(block1);
        let f2 = ipfs.put_dag(block2);
        let (res1, res2) = join!(f1, f2);
        let root: Ipld = vec![res1.unwrap(), res2.unwrap()].into();
        let path = ipfs.put_dag(root).await.unwrap();

        // Query the DAG
        let path1 = path.sub_path("0").unwrap();
        let path2 = path.sub_path("1").unwrap();
        let f1 = ipfs.get_dag(path1);
        let f2 = ipfs.get_dag(path2);
        let (res1, res2) = join!(f1, f2);
        println!("Received block with contents: {:?}", res1.unwrap());
        println!("Received block with contents: {:?}", res2.unwrap());

        // Exit
        ipfs.exit_daemon();
    }.unit_error().boxed().compat()).unwrap();
}

Note: rust-ipfs currently requires nightly, see rust-toolchain and .travis.yml for the tested version.

License

Dual licensed under MIT or Apache License (Version 2.0). See LICENSE-MIT and LICENSE-APACHE for more details.