Trait ImageGenerator

Source
pub trait ImageGenerator {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn create(
        &self,
        prompt: Prompt,
        size: Size,
    ) -> impl Stream<Item = Result<Data, Self::Error>> + Unpin + Send;
    fn edit(
        &self,
        prompt: Prompt,
        mask: &[u8],
    ) -> impl Stream<Item = Result<Data, Self::Error>> + Unpin + Send;
}
Expand description

Trait for generating and editing images from prompts and masks.

Images are returned as a stream where each item represents a complete image with progressively improving quality, allowing for real-time preview during generation.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

The error type returned by the image generator.

Required Methods§

Source

fn create( &self, prompt: Prompt, size: Size, ) -> impl Stream<Item = Result<Data, Self::Error>> + Unpin + Send

Create an image from a prompt and a specified size.

§Arguments
  • prompt - The prompt containing text and optional images.
  • size - The desired size of the generated image.
§Returns

A stream where each item is a complete image with progressively improving quality.

Source

fn edit( &self, prompt: Prompt, mask: &[u8], ) -> impl Stream<Item = Result<Data, Self::Error>> + Unpin + Send

Edit an image using a prompt and a mask.

§Arguments
  • prompt - The prompt containing text and optional images.
  • mask - The mask to apply to the image data.
§Returns

A stream where each item is a complete image with progressively improving quality.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: ImageGenerator> ImageGenerator for Box<T>

Source§

type Error = <T as ImageGenerator>::Error

Source§

fn create( &self, prompt: Prompt, size: Size, ) -> impl Stream<Item = Result<Data, Self::Error>> + Unpin + Send

Source§

fn edit( &self, prompt: Prompt, mask: &[u8], ) -> impl Stream<Item = Result<Data, Self::Error>> + Unpin + Send

Source§

impl<T: ImageGenerator> ImageGenerator for Arc<T>

Source§

type Error = <T as ImageGenerator>::Error

Source§

fn create( &self, prompt: Prompt, size: Size, ) -> impl Stream<Item = Result<Data, Self::Error>> + Unpin + Send

Source§

fn edit( &self, prompt: Prompt, mask: &[u8], ) -> impl Stream<Item = Result<Data, Self::Error>> + Unpin + Send

Implementors§