8 releases

Uses old Rust 2015

0.3.5 Feb 18, 2018
0.3.3 Jan 26, 2018
0.3.0 Dec 30, 2017
0.2.0 Dec 17, 2017
0.1.1 Oct 9, 2017

#1784 in #api

MIT license

1MB
1.5K SLoC

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

Dependencies

~19–31MB
~537K SLoC