rust-ipfs/examples/client2.rs

25 lines
752 B
Rust
Raw Normal View History

2020-02-23 14:10:51 +01:00
use futures::join;
use ipfs::{Ipfs, IpfsPath, TestTypes, UninitializedIpfs};
2020-02-23 14:10:51 +01:00
use std::str::FromStr;
use tokio::task;
2019-02-22 15:56:52 +01:00
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
2020-02-23 14:10:51 +01:00
let path =
IpfsPath::from_str("/ipfs/zdpuB1caPcm4QNXeegatVfLQ839Lmprd5zosXGwRUBJHwj66X").unwrap();
2019-02-21 22:28:59 +01:00
let (ipfs, fut): (Ipfs<TestTypes>, _) =
UninitializedIpfs::default().await.start().await.unwrap();
task::spawn(fut);
2019-02-21 22:28:59 +01:00
let f1 = ipfs.get_dag(path.sub_path("0").unwrap());
let f2 = ipfs.get_dag(path.sub_path("1").unwrap());
let (res1, res2) = join!(f1, f2);
println!("Received block with contents: {:?}", res1.unwrap());
println!("Received block with contents: {:?}", res2.unwrap());
2019-02-27 19:11:12 +01:00
ipfs.exit_daemon().await;
2019-02-13 23:46:55 +01:00
}