pub trait ImageResolver: Send + Sync {
// Required method
fn resolve_image<'life0, 'async_trait>(
&'life0 self,
image_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<ResolvedImage>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Trait for resolving image_file content parts to actual image data
When building LLM messages, image_file content parts contain only
a reference (UUID) to an uploaded image. This trait allows resolving
those references to actual image data.
§Provider-specific formatting
The resolved image data is then converted to provider-specific formats:
OpenAI Vision:
{
"type": "image_url",
"image_url": { "url": "data:image/png;base64,..." }
}Anthropic Vision:
{
"type": "image",
"source": { "type": "base64", "media_type": "image/png", "data": "..." }
}§Implementation notes
Implementations should:
- Fetch image data from storage (database, S3, etc.)
- Return base64-encoded data with media type
- Handle missing images gracefully (return None)
Required Methods§
Sourcefn resolve_image<'life0, 'async_trait>(
&'life0 self,
image_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<ResolvedImage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn resolve_image<'life0, 'async_trait>(
&'life0 self,
image_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<ResolvedImage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Resolve an image_file reference to actual image data
Returns None if the image is not found.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".