img_src 0.3.2

Rust SDK for img-src image processing and delivery API
Documentation
/*
 * img-src API
 *
 * Image processing and delivery API.  A serverless image processing and delivery API built on Cloudflare Workers with parameter-driven image transformation and on-demand transcoding.  ## Features  - **Image Upload**: Store original images in R2 with SHA256-based deduplication - **On-Demand Transformation**: Resize, crop, and convert images via URL parameters - **Format Conversion**: WebP, AVIF, JPEG, PNG output formats - **Path Organization**: Organize images into folders with multiple paths per image - **CDN Caching**: Automatic edge caching for transformed images  ## Authentication  Authenticate using API Keys with `imgsrc_` prefix. Create your API key at https://img-src.io/settings  ## Rate Limiting  - **Free Plan**: 100 requests/minute - **Pro Plan**: 500 requests/minute  Rate limit headers are included in all responses.
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: taehun@taehun.dev
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct UploadResponse {
    /// Image ID (first 16 characters of SHA256 hash)
    #[serde(rename = "id")]
    pub id: String,
    /// Full SHA256 hash of the image content
    #[serde(rename = "hash")]
    pub hash: String,
    /// Primary CDN URL for the image
    #[serde(rename = "url")]
    pub url: String,
    /// All paths where this image is accessible
    #[serde(rename = "paths")]
    pub paths: Vec<String>,
    /// Whether this is a newly uploaded image (false if duplicate)
    #[serde(rename = "is_new", skip_serializing_if = "Option::is_none")]
    pub is_new: Option<bool>,
    /// Image visibility (public or private)
    #[serde(rename = "visibility")]
    pub visibility: String,
    /// File size in bytes
    #[serde(rename = "size")]
    pub size: i64,
    /// Detected image format
    #[serde(rename = "format")]
    pub format: String,
    #[serde(rename = "dimensions", skip_serializing_if = "Option::is_none")]
    pub dimensions: Option<Box<models::ImageDimensions>>,
    #[serde(rename = "available_formats")]
    pub available_formats: Box<models::AvailableFormats>,
    /// Upload timestamp (RFC3339 format)
    #[serde(rename = "uploaded_at")]
    pub uploaded_at: String,
    #[serde(rename = "_links")]
    pub _links: Box<models::HateoasLinks>,
}

impl UploadResponse {
    pub fn new(
        id: String,
        hash: String,
        url: String,
        paths: Vec<String>,
        visibility: String,
        size: i64,
        format: String,
        available_formats: models::AvailableFormats,
        uploaded_at: String,
        _links: models::HateoasLinks,
    ) -> UploadResponse {
        UploadResponse {
            id,
            hash,
            url,
            paths,
            is_new: None,
            visibility,
            size,
            format,
            dimensions: None,
            available_formats: Box::new(available_formats),
            uploaded_at,
            _links: Box::new(_links),
        }
    }
}