Skip to main content

Asset

Trait Asset 

Source
pub trait Asset:
    Sized
    + Send
    + Sync
    + 'static {
    const KIND: &'static str;

    // Required method
    fn decode(bytes: &[u8], context: &LoadContext) -> Result<Self>;

    // Provided method
    fn retained_bytes(&self) -> usize { ... }
}
Expand description

A custom typed resource decoded once for a shared source and project context.

Required Associated Constants§

Source

const KIND: &'static str

Human-readable resource category retained by load diagnostics.

Required Methods§

Source

fn decode(bytes: &[u8], context: &LoadContext) -> Result<Self>

Decodes bounded input without requiring a rendering device. Implementations must be deterministic for these bytes/context; recursive resource dependency graphs are not a supported decoder contract.

Provided Methods§

Source

fn retained_bytes(&self) -> usize

Logical decoded payload charge; custom heap-owning assets should override. At least the encoded input length is charged regardless of this value.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§