Public declaration syntax from forge-rs/crates/forge-media/src/image.rs Original source SHA-256: 792e2d275812ea8f56797ef026fdb45fc3c1ec57c3424d9070ccba72070f78e5 Function bodies and constant values are omitted. This is not the complete implementation. Source line 48 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum ImageFormat { /// PNG (Portable Network Graphics) — lossless compression. #[default] Png, /// JPEG — lossy compression, smaller file sizes. Jpeg, /// WebP — modern format with both lossy and lossless modes. Webp, } Source line 74 pub fn mime_type(&self) -> &'static str; Source line 93 pub fn extension(&self) -> &'static str; Source line 129 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ImageOptions { /// Desired width in pixels. pub width: u32, /// Desired height in pixels. pub height: u32, /// Output image format. pub format: ImageFormat, /// Output quality (0-100). Applicable to lossy formats like JPEG and WebP. /// `None` means the provider's default quality. pub quality: Option, /// Style hint for the generation model (e.g., "photorealistic", "watercolor"). /// `None` means the provider's default style. pub style: Option } Source line 176 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ImageResult { /// The raw image bytes in the format specified by `mime_type`. pub data: Vec, /// The MIME type of the image data (e.g., "image/png"). pub mime_type: String, /// The width of the generated image in pixels. pub width: u32, /// The height of the generated image in pixels. pub height: u32, /// The model that generated this image (e.g., "dall-e-3"). pub model: String } Source line 232 #[async_trait] pub trait ImageProvider: Send + Sync { /// Returns the model identifier (e.g., "dall-e-3", "stable-diffusion-xl"). fn model_id(&self) -> &str; /// Returns the provider name (e.g., "openai", "stability"). fn provider_name(&self) -> &str; /// Generates an image from a text prompt. /// /// # Arguments /// /// * `prompt` - The text description of the image to generate. /// * `options` - Configuration for output dimensions, format, quality, and style. /// /// # Returns /// /// An [`ImageResult`] containing the generated image bytes and metadata. /// /// # Errors /// /// * [`ForgeMediaError::GenerationFailed`] -- if the provider returns an error. /// * [`ForgeMediaError::UnsupportedFormat`] -- if the requested format is not supported. async fn generate_image( &self, prompt: &str, options: &ImageOptions, ) -> Result; } Source line 301 pub async fn generate_image( provider: &dyn ImageProvider, prompt: &str, options: &ImageOptions, ) -> Result;