Skip to main content

AssetProvider

Trait AssetProvider 

Source
pub trait AssetProvider: Send + Sync {
    // Required methods
    fn content_type(&self, asset_id: &str) -> Option<Cow<'_, str>>;
    fn stream_to(
        &self,
        asset_id: &str,
        writer: &mut dyn Write,
    ) -> Option<Result<u64>>;
}
Expand description

Provides access to binary assets referenced in the event stream.

Readers register assets as they are encountered. Writers call AssetProvider::stream_to on demand — bytes stream through, never buffer. Assets must remain accessible until the EndDocument event is processed.

Required Methods§

Source

fn content_type(&self, asset_id: &str) -> Option<Cow<'_, str>>

Returns the MIME content type for the given asset ID, or None if the asset is not found.

Source

fn stream_to( &self, asset_id: &str, writer: &mut dyn Write, ) -> Option<Result<u64>>

Streams the asset bytes to the given writer.

Returns Some(Ok(bytes_written)) on success, Some(Err(_)) on write error, or None if the asset is not found.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§