LoadableResource

Trait LoadableResource 

Source
pub trait LoadableResource: Any {
    // Required methods
    fn load(
        path: PathBuf,
        texture_creator: &Arc<TextureCreator<WindowContext>>,
    ) -> Result<Box<dyn LoadableResource>>
       where Self: Sized;
    fn name(&self) -> String;
    fn as_mut_slice(&self) -> &mut [u8] ;
    fn as_slice(&self) -> Ref<'_, [u8]>;
}
Expand description

Trait that all loadable assets must implement

Required Methods§

Source

fn load( path: PathBuf, texture_creator: &Arc<TextureCreator<WindowContext>>, ) -> Result<Box<dyn LoadableResource>>
where Self: Sized,

Load a resource from path and return it boxed

§Errors

Returns an error if the file cannot be read or parsed

Source

fn name(&self) -> String

Eaasy-to-use identifier for the resource

Source

fn as_mut_slice(&self) -> &mut [u8]

Return a mutable slice that the graphics thread can pass to SDL

Source

fn as_slice(&self) -> Ref<'_, [u8]>

Return an immutable slice for read‑only access

Implementors§