Skip to main content

AssetHandle

Trait AssetHandle 

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

A self-contained handle to a single embedded asset.

Returned by readers inside ImageSource::Asset(Arc<dyn AssetHandle>). The handle carries everything needed to resolve content type and stream bytes — no external provider lookup is required.

Required Methods§

Source

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

MIME content type (e.g. "image/png"). None means unknown.

Source

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

Stream the asset bytes to writer. Returns total bytes written.

§Errors

Returns io::Error if the underlying source fails or the asset is no longer accessible (e.g. ZIP entry vanished, mutex poisoned).

Source

fn asset_id(&self) -> &str

Opaque identifier used for Debug formatting and PartialEq on ImageSource::Asset. Format is reader-defined (e.g. "zip://word/media/image1.png").

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§