Crates.io | gyazo_client |
lib.rs | gyazo_client |
version | |
source | src |
created_at | 2024-07-15 10:15:23.269721 |
updated_at | 2024-07-15 13:20:49.79687 |
description | Gyazo Client for Rust |
homepage | https://github.com/katayama8000/gyazo-client-rust/blob/main/README.md |
repository | https://github.com/katayama8000/gyazo-client-rust |
max_upload_size | |
id | 1303664 |
size | 0 |
A Rust library for interacting with the Gyazo API. Upload, retrieve, list, and delete images on Gyazo efficiently.
cargo add gyazo_client
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());
// 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 URL
let oembed_url = gyazo_client.get_oembed(&upload_response.image_id).await?;
Ok(())
}