Access proxer.me with rust
Making requests is fairly simple:
```rust let prxr = proxer::Client::new("yourapikey"); // or load the api-key from an environment variable let prxr = proxer::Client::withenvkey("PROXERAPIKEY");
let req = client.api().info().getfullentry( // this struct is equivalent to the documented parameters // for this endpoint. See http://proxer.me/wiki/ProxerAPI/v1/Info#GetFullEntry parameter::InfoGetFullEntry { id: 53 } );
// send the request match req.send() { 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 Iterator
s for pageable endpoints.
```rust let req = client.api().info().get_comments( parameter::InfoGetComments { id: 53, p: None, limit: None, sort: None } );
for comment in req.pager() { // Now, new comments are automagically fetched when a page end is reached
println!("user: {}", comment.unwrap().username); println!("rating: {}", comment.unwrap().rating); } ```