A simple Rust API wrapper that generates images & facts of any animal.
Add this to your Cargo.toml file's dependencies:
toml
animality = "1.0.0"
```rust extern crate animality; use animality::{Animality, Animal};
fn main() { let client = Animality::new("your token here");
// request with the Animal
enum
let dogimage = client.image(Animal::Dog).unwrap();
let dogfact = client.fact(Animal::Dog).unwrap();
// request from a string (case-insensitive) let cat: Animal = "cat".parse().unwrap(); let catimage = client.image(cat).unwrap(); let catfact = client.fact(cat).unwrap(); } ```
```rust extern crate animality; extern crate tokio;
use animality::{Animality, Animal, RequestError};
async fn main() -> Result<(), RequestError> { let client = Animality::new("your token here");
// request with the Animal
enum
let dogimage = client.imageasync(Animal::Dog).await?;
let dogfact = client.factasync(Animal::Dog).await?;
// request from a string (case-insensitive) let cat: Animal = "cat".parse().unwrap(); let catimage = client.imageasync(cat).await?; let catfact = client.factasync(cat).await?;
Ok(()) } ```