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 Update README. 2020-03-03 13:00:21 +01:00


Rust IPFS

Build Status Back on OpenCollective Matrix Discord

Getting started

use async_std::task;
use futures::join;
use ipfs::{IpfsOptions, Ipld, Types, UninitializedIpfs};

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

    task::block_on(async move {
        // Start daemon and initialize repo
        let (ipfs, fut) = UninitializedIpfs::new(options).await.start().await.unwrap();
        task::spawn(fut);

        // 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();
    });
}

License

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