Mark Robert Henderson 83442932c8 Adding
2020-03-05 09:52:37 +01:00
2020-03-05 09:50:22 +01:00
2020-03-03 13:00:21 +01:00
2020-03-03 13:00:21 +01:00
2019-01-30 15:03:09 +01:00
2020-02-06 18:42:34 +01:00
2020-03-03 13:00:21 +01:00
2020-03-03 13:00:21 +01:00
2020-03-05 09:52:37 +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.

Trademarks

The Rust logo and wordmark are trademarks owned and protected by the Mozilla Foundation. The Rust and Cargo logos (bitmap and vector) are owned by Mozilla and distributed under the terms of the Creative Commons Attribution license (CC-BY).

Description
No description provided
Readme 59 MiB
Languages
Rust 99%
JavaScript 0.6%
Shell 0.4%