rust-ipfs/examples/client2.rs

24 lines
862 B
Rust
Raw Normal View History

2019-12-27 12:28:25 +02:00
use std::str::FromStr;
use ipfs::{UninitializedIpfs, IpfsOptions, IpfsPath, TestTypes};
2019-02-27 19:11:12 +01:00
use futures::join;
2020-02-23 14:10:32 +01:00
use async_std::task;
2019-02-22 15:56:52 +01:00
2019-02-13 23:46:55 +01:00
fn main() {
let options = IpfsOptions::<TestTypes>::default();
env_logger::Builder::new().parse_filters(&options.ipfs_log).init();
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();
2020-02-23 14:10:32 +01:00
});
2019-02-13 23:46:55 +01:00
}