9 releases

0.2.7 Aug 15, 2024
0.2.6 Aug 15, 2024
0.2.3 Jul 21, 2024
0.1.2 Jul 15, 2024

#198 in HTTP client

Download history 109/week @ 2024-07-19 38/week @ 2024-07-26 2/week @ 2024-08-02 297/week @ 2024-08-09 131/week @ 2024-08-16 5/week @ 2024-09-13 6/week @ 2024-09-20 6/week @ 2024-09-27 1/week @ 2024-10-04

445 downloads per month

MIT/Apache

26KB
568 lines

Gyazo Client for Rust

A Rust library for interacting with the Gyazo API. Upload, retrieve, list, and delete images on Gyazo efficiently.

ci crates.io docs.rs license

Features

  • Upload, retrieve, list, and delete images
  • Asynchronous API using tokio and reqwest
  • Custom error handling

Installation

cargo add gyazo_client

Usage

use gyazo_client::{GyazoClient, UploadParams, UploadParamsBuilder};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize the Gyazo client with your access token
    let gyazo_client = GyazoClient::new("YOUR_ACCESS_TOKEN".to_string(), ..Default::default());

    // Upload an image with a title and metadata_is_public
    let image_data = std::fs::read("path/to/your/image.png")?;
    let upload_params = UploadParamsBuilder::new(image_data)
        .title("My awesome image".to_string())
        .metadata_is_public("true".to_string())
        .build()?;
    let upload_response = gyazo_client.upload_image(upload_params).await?;

    // Get image
    let image = gyazo_client.get_image(&upload_response.image_id).await?;

    // List images
    let images = gyazo_client.list_images().await?;

    // Delete an image
    let delete_response = gyazo_client.delete_image(&upload_response.image_id).await?;

    // Get oEmbed data
    let oembed_url = gyazo_client.get_oembed(&upload_response.image_id).await?;

    Ok(())
}

References

Dependencies

~5–16MB
~201K SLoC