diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2017-12-03 16:32:03 -0500 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2017-12-03 16:32:03 -0500 |
commit | bf53ecbf41d7c93f417f8f11c2affdda234e15b7 (patch) | |
tree | 56241358ec655870d639ced25801d4afe99cc5f0 /README.md | |
parent | 96a3854ece8f61d71c440498745b7b0054757753 (diff) |
finish up adding documentation
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 66 |
1 files changed, 54 insertions, 12 deletions
@@ -1,23 +1,65 @@ -## Rust IPFS API Library +# ipfs-api + +[![Travis](https://img.shields.io/travis/ferristseng/rust-ipfs-api.svg)](https://travis-ci.org/ferristseng/rust-ipfs-api) +[![Crates.io](https://img.shields.io/crates/v/ipfs-api.svg)](https://crates.io/crates/ipfs-api) +[![Docs.rs](https://docs.rs/ipfs-api/badge.svg)](https://docs.rs/ipfs-api/) + +Rust library for connecting to the IPFS HTTP API using tokio. + +### Usage ```toml [dependencies] -ipfs-api = "0.4.0" +ipfs-api = "0.4.0-alpha" ``` -### Goals +### Examples + +Write a file to IPFS: - * Provide a full implementation of the HTTP API specification described here: https://ipfs.io/docs/api/. - * Write idiomatic rust, and make use of rust's memory safety features. - * Provide support for `go-ipfs 0.4.*`, with possible backwards compatibility features. - * Feature parity with the `go-ipfs` cli. - * Provide cross platform support for Linux, OSX, and Windows. +```rust +# +use ipfs_api::IpfsClient; +use std::io::Cursor; +use tokio_core::reactor::Core; + +let mut core = Core::new().unwrap(); +let client = IpfsClient::default(&core.handle()); +let data = Cursor::new("Hello World!"); + +let req = client.add(data); +let res = core.run(req).unwrap(); + +println!("{}", res.hash); +``` -#### Maybe (?) +Read a file from IPFS: - * Add integration tests for the `go-ipfs` implementation, and `js-ipfs` implementation of the ipfs spec. - * Explore a higher level API for interacting with IPFS. - * File system abstraction +```rust +# +use futures::stream::Stream; +use ipfs_api::IpfsClient; +use std::io::{self, Write}; +use tokio_core::reactor::Core; + +let mut core = Core::new().unwrap(); +let client = IpfsClient::default(&core.handle()); + +let req = client.get("/test/file.json").concat2(); +let res = core.run(req).unwrap(); +let out = io::stdout(); +let mut out = out.lock(); + +out.write_all(&res).unwrap(); +``` +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: + +```sh +$ cargo run -p ipfs-api --example add_file +``` ## License |