Expand description
This crate is an unofficial implementation of the Imgur API in Rust.
§Installation
§Requirements
- Rust 1.58 (earlier versions are not tested (only the latest stable version is tested!))
- Network connection
§Importing
The driver is available on crates.io. To use the driver in
your application, simply add it to your project’s Cargo.toml.
[dependencies]
imgurs = "0.8.0"§Example Usage
§Create new ImgurClient
use imgurs::ImgurClient;
let client = ImgurClient::new("client_id");§Image Upload
use imgurs::ImgurClient;
#[tokio::main]
async fn main() {
let client = ImgurClient::new("client_id");
// From URL
let info = client
.upload_image("https://i.imgur.com/lFaGr1x.png")
.await
.unwrap();
println!("{:?}", info);
// From File
let info = client.upload_image("path/to/file.png").await.unwrap();
println!("{:?}", info);
}§Delete Image
use imgurs::ImgurClient;
#[tokio::main]
async fn main() {
let client = ImgurClient::new("client_id");
client.delete_image("delete_hash").await.unwrap(); // delete hash
}§Get Image Info
use imgurs::ImgurClient;
#[tokio::main]
async fn main() {
let client = ImgurClient::new("client_id");
let info = client.image_info("lFaGr1x").await.unwrap(); // image id
println!("{:?}", info);
}§Get Client RateLimit
use imgurs::ImgurClient;
#[tokio::main]
async fn main() {
let client = ImgurClient::new("client_id");
let info = client.rate_limit().await.unwrap();
println!("{:?}", info);
}Structs§
- AdConfig
- Album
Info - Album Info Response
- Album
Info Data - Image
Info - Image Info Response
- Image
Info Data - Image Info Reponse (
datajson) - Imgur
Client - Imgur Client
Enums§
Functions§
- send_
api_ request - Send request to a Imgur API
Type Aliases§
- Result
- A
Resultalias where theErrcase isimgurs::Error