2022-06-12 15:28:25 +00:00
|
|
|
//! [![github]](https://github.com/MedzikUser/imgurs)
|
|
|
|
//! [![crates-io]](https://crates.io/crates/imgurs)
|
|
|
|
//! [![docs-rs]](https://docs.rs/imgurs)
|
|
|
|
//!
|
|
|
|
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
|
|
|
|
//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
|
|
|
|
//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs
|
|
|
|
//!
|
2022-05-18 17:48:39 +00:00
|
|
|
//! This crate is an unofficial implementation of the [Imgur API](https://imgur.com) in Rust.
|
2022-04-03 19:32:42 +00:00
|
|
|
//!
|
|
|
|
//! # 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](https://crates.io/crates/imgurs). To use the driver in
|
|
|
|
//! your application, simply add it to your project's `Cargo.toml`.
|
|
|
|
//! ```toml
|
|
|
|
//! [dependencies]
|
2022-06-12 15:38:52 +00:00
|
|
|
//! imgurs = "0.8.0"
|
2022-04-03 19:32:42 +00:00
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! # Example Usage
|
|
|
|
//!
|
|
|
|
//! ## Create new ImgurClient
|
2022-06-12 15:28:25 +00:00
|
|
|
//! ```
|
2022-04-03 19:32:42 +00:00
|
|
|
//! use imgurs::ImgurClient;
|
|
|
|
//!
|
2022-06-17 21:00:45 +00:00
|
|
|
//! let client = ImgurClient::new("client_id");
|
2022-04-03 19:32:42 +00:00
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! ## Image Upload
|
2022-06-12 16:22:45 +00:00
|
|
|
//! ```no_run
|
2022-06-17 21:00:45 +00:00
|
|
|
//! use imgurs::ImgurClient;
|
|
|
|
//!
|
|
|
|
//! #[tokio::main]
|
|
|
|
//! async fn main() {
|
|
|
|
//! let client = ImgurClient::new("client_id");
|
2022-04-03 19:32:42 +00:00
|
|
|
//!
|
2022-06-17 21:00:45 +00:00
|
|
|
//! // 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);
|
|
|
|
//! }
|
2022-04-03 19:32:42 +00:00
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! ## Delete Image
|
2022-06-12 16:22:45 +00:00
|
|
|
//! ```no_run
|
2022-06-17 21:00:45 +00:00
|
|
|
//! use imgurs::ImgurClient;
|
|
|
|
//!
|
|
|
|
//! #[tokio::main]
|
|
|
|
//! async fn main() {
|
|
|
|
//! let client = ImgurClient::new("client_id");
|
|
|
|
//!
|
|
|
|
//! client.delete_image("delete_hash").await.unwrap(); // delete hash
|
|
|
|
//! }
|
2022-04-03 19:32:42 +00:00
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! ## Get Image Info
|
2022-06-12 16:22:45 +00:00
|
|
|
//! ```no_run
|
2022-06-17 21:00:45 +00:00
|
|
|
//! use imgurs::ImgurClient;
|
2022-04-03 19:32:42 +00:00
|
|
|
//!
|
2022-06-17 21:00:45 +00:00
|
|
|
//! #[tokio::main]
|
|
|
|
//! async fn main() {
|
|
|
|
//! let client = ImgurClient::new("client_id");
|
|
|
|
//!
|
|
|
|
//! let info = client.image_info("lFaGr1x").await.unwrap(); // image id
|
|
|
|
//!
|
|
|
|
//! println!("{:?}", info);
|
|
|
|
//! }
|
2022-04-03 19:32:42 +00:00
|
|
|
//! ```
|
|
|
|
//!
|
|
|
|
//! ## Get Client RateLimit
|
2022-06-12 16:22:45 +00:00
|
|
|
//! ```no_run
|
2022-06-17 21:00:45 +00:00
|
|
|
//! use imgurs::ImgurClient;
|
2022-04-03 19:32:42 +00:00
|
|
|
//!
|
2022-06-17 21:00:45 +00:00
|
|
|
//! #[tokio::main]
|
|
|
|
//! async fn main() {
|
|
|
|
//! let client = ImgurClient::new("client_id");
|
|
|
|
//!
|
|
|
|
//! let info = client.rate_limit().await.unwrap();
|
|
|
|
//!
|
|
|
|
//! println!("{:?}", info);
|
|
|
|
//! }
|
2022-04-03 19:32:42 +00:00
|
|
|
//! ```
|
|
|
|
|
2022-08-24 13:35:51 +00:00
|
|
|
mod error;
|
|
|
|
pub use error::*;
|
2022-04-03 19:01:58 +00:00
|
|
|
|
2022-08-24 13:35:51 +00:00
|
|
|
#[cfg(feature = "imgur")]
|
|
|
|
mod imgur;
|
|
|
|
|
|
|
|
#[cfg(feature = "imgur")]
|
|
|
|
pub use imgur::*;
|