Rust library for connecting to the IPFS HTTP API using tokio.
Usage
[]
= "0.5.0-alpha1"
Examples
Write a file to IPFS:
# extern crate hyper;
# extern crate ipfs_api;
#
use hyper::rt::Future;
use ipfs_api::IpfsClient;
use std::io::Cursor;
# fn main() {
let client = IpfsClient::default();
let data = Cursor::new("Hello World!");
let req = client
.add(data)
.map(|res| {
println!("{}", res.hash);
})
.map_err(|e| eprintln!("{}", e));
hyper::rt::run(req);
# }
Read a file from IPFS:
# extern crate futures;
# extern crate hyper;
# extern crate ipfs_api;
#
use futures::{Future, Stream};
use ipfs_api::IpfsClient;
use std::io::{self, Write};
# fn main() {
let client = IpfsClient::default();
let req = client
.get("/test/file.json")
.concat2()
.map(|res| {
let out = io::stdout();
let mut out = out.lock();
out.write_all(&res).unwrap();
})
.map_err(|e| eprintln!("{}", e));
hyper::rt::run(req);
# }
There are also a bunch of examples included in the project, which I used for testing
You can run any of the examples with cargo: