Skip to main content

ImageModelMiddleware

Trait ImageModelMiddleware 

Source
pub trait ImageModelMiddleware:
    Send
    + Sync
    + Debug {
    // Provided methods
    fn override_provider(&self, _inner: &dyn ImageModel) -> Option<String> { ... }
    fn override_model_id(&self, _inner: &dyn ImageModel) -> Option<String> { ... }
    fn override_max_images_per_call<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _inner: &'life1 dyn ImageModel,
    ) -> Pin<Box<dyn Future<Output = Option<Option<u32>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn transform_params<'life0, 'life1, 'async_trait>(
        &'life0 self,
        params: ImageOptions,
        _inner: &'life1 dyn ImageModel,
    ) -> Pin<Box<dyn Future<Output = Result<ImageOptions>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn wrap_generate<'life0, 'life1, 'async_trait>(
        &'life0 self,
        next: &'life1 dyn ImageModel,
        params: ImageOptions,
    ) -> Pin<Box<dyn Future<Output = Result<ImageResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Contract for middleware that decorates an ImageModel.

Provided Methods§

Source

fn override_provider(&self, _inner: &dyn ImageModel) -> Option<String>

Override the provider id exposed by the wrapped model.

Source

fn override_model_id(&self, _inner: &dyn ImageModel) -> Option<String>

Override the model id exposed by the wrapped model.

Source

fn override_max_images_per_call<'life0, 'life1, 'async_trait>( &'life0 self, _inner: &'life1 dyn ImageModel, ) -> Pin<Box<dyn Future<Output = Option<Option<u32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn transform_params<'life0, 'life1, 'async_trait>( &'life0 self, params: ImageOptions, _inner: &'life1 dyn ImageModel, ) -> Pin<Box<dyn Future<Output = Result<ImageOptions>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Transform the image options before they reach the inner model.

§Errors

Return a crate::ProviderError to fail the call without invoking the model.

Source

fn wrap_generate<'life0, 'life1, 'async_trait>( &'life0 self, next: &'life1 dyn ImageModel, params: ImageOptions, ) -> Pin<Box<dyn Future<Output = Result<ImageResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Wrap an image-generation call.

Default: forwards to next.do_generate(params).

§Errors

Returns whatever error next returns, or a middleware-introduced failure.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§