rust-ipfs/examples/client2.rs

25 lines
828 B
Rust
Raw Normal View History

2020-02-23 14:10:32 +01:00
use async_std::task;
2020-02-23 14:10:51 +01:00
use futures::join;
use ipfs::{IpfsOptions, IpfsPath, TestTypes, UninitializedIpfs};
use std::str::FromStr;
2019-02-22 15:56:52 +01:00
2019-02-13 23:46:55 +01:00
fn main() {
2020-03-21 12:52:51 -03:00
env_logger::init();
let options = IpfsOptions::<TestTypes>::default();
2020-02-23 14:10:51 +01:00
let path =
IpfsPath::from_str("/ipfs/zdpuB1caPcm4QNXeegatVfLQ839Lmprd5zosXGwRUBJHwj66X").unwrap();
2019-02-21 22:28:59 +01:00
2020-02-23 14:10:32 +01:00
task::block_on(async move {
2020-01-08 23:30:46 +01:00
let (ipfs, fut) = UninitializedIpfs::new(options).await.start().await.unwrap();
2020-02-23 14:10:32 +01:00
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());
2019-02-27 19:11:12 +01:00
let (res1, res2) = join!(f1, f2);
println!("Received block with contents: {:?}", res1.unwrap());
println!("Received block with contents: {:?}", res2.unwrap());
ipfs.exit_daemon().await;
2020-02-23 14:10:32 +01:00
});
2019-02-13 23:46:55 +01:00
}