proxer

Crates.ioproxer
lib.rsproxer
version0.3.5
sourcesrc
created_at2017-10-08 18:27:56.163681
updated_at2018-02-18 18:19:16.901618
descriptionAccess the ProxerMe API with Rust
homepagehttps://0x000.net/proxer-rs
repositoryhttps://github.com/cuechan/proxer-rs
max_upload_size
id34902
size1,180,718
Paul Maruhn (cuechan)

documentation

https://docs.rs/proxer

README

proxer-rs

cates.io maintenance Build Status

Access proxer.me with rust

Examples

You can find all examples in the ./examplesdirectory and run these with cargo run --example <example-name>. However, here is a small summary:

Making requests is fairly simple:

let prxr = proxer::Client::new("yourapikey");
// ...or load the api-key from an environment variable
let prxr = proxer::Client::with_env_key("PROXER_API_KEY");


// everything is strong typed. You can't pass wrong parameters
let req = api::info::GetFullEntry { id: 53 };


// execute the request
let res = prxr.execute(req).unwrap();

// check the response
match res {
  Ok(data) => println!("{:#?}", data),
  Err(e) => {
    match e {
      error::Error::Api(k)  => panic!("API error: {}", k),
      error::Error::Json(k) => panic!("something is wrong: ", k),
      error::Error::Http    => panic!("interwebs error"),
      error::Error::Unknown => panic!("i dont know what happened"),
    }
  }
}

This example creates a api object and fetches the full data for an entry

The library is as strong typed as possible (which is a good thing for guaranteeing type safety). It tries to be a 1:1 wrapper to the api while providing some nice tweaks like Iterators for pageable endpoints.

let prxr = Client::with_env_key("PROXER_API_KEY").unwrap();

let req = api::info::GetComments {
  id: 53,
  p: None,
  limit: Some(100),
  sort: None,
};

// create a pager(`Iterator`) for the request
let pager = req.pager(prxr);
// iterate over the list
for comment in pager {
  // Now, new comments are automagically fetched when the end of a page is reached
  // there is still some error handling
  let comment = comment.expect("something went wrong");
  println!("{}: {}", comment.username, comment.rating);
}

Dependencies

Dependency graph

Commit count: 215

cargo fmt