pub trait ResourceData: 'static + Debug + Visit + Send + Reflect {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
    fn type_uuid(&self) -> Uuid;
    fn save(&mut self, path: &Path) -> Result<(), Box<dyn Error>>;
    fn can_be_saved(&self) -> bool;
}
Expand description

A trait for resource data.

Required Methods§

source

fn as_any(&self) -> &dyn Any

Returns self as &dyn Any. It is useful to implement downcasting to a particular type.

source

fn as_any_mut(&mut self) -> &mut dyn Any

Returns self as &mut dyn Any. It is useful to implement downcasting to a particular type.

source

fn type_uuid(&self) -> Uuid

Returns unique data type id.

source

fn save(&mut self, path: &Path) -> Result<(), Box<dyn Error>>

Saves the resource data a file at the specified path. This method is free to decide how the resource data is saved. This is needed, because there are multiple formats that defines various kinds of resources. For example, a rectangular texture could be saved into a whole bunch of formats, such as png, bmp, tga, jpg etc, but in the engine it is single Texture resource. In any case, produced file should be compatible with a respective resource loader.

source

fn can_be_saved(&self) -> bool

Returns true if the resource data can be saved to a file, false - otherwise. Not every resource type supports saving, for example there might be temporary resource type that is used only at runtime which does not need saving at all.

Implementors§