Trait fyrox_resource::ResourceData
source · 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§
sourcefn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Returns self
as &dyn Any
. It is useful to implement downcasting to a particular type.
sourcefn as_any_mut(&mut self) -> &mut dyn Any
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.
sourcefn save(&mut self, path: &Path) -> Result<(), Box<dyn Error>>
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.
sourcefn can_be_saved(&self) -> bool
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.