[][src]Trait amethyst_assets::Format

pub trait Format<D: 'static>: Clone + Debug + Send + Sync + 'static {
    fn name(&self) -> &'static str;

    fn import_simple(&self, _bytes: Vec<u8>) -> Result<D, Error> { ... }
fn import(
        &self,
        name: String,
        source: Arc<dyn Source>,
        create_reload: Option<Box<dyn Format<D>>>
    ) -> Result<FormatValue<D>, Error> { ... } }

A format, providing a conversion from bytes to asset data, which is then in turn accepted by Asset::from_data. Examples for formats are Png, Obj and Wave.

The format type itself represents loading options, which are passed to import. E.g. for textures this would be stuff like mipmap levels and sampler info.

Required methods

fn name(&self) -> &'static str

A unique identifier for this format.

Loading content...

Provided methods

fn import_simple(&self, _bytes: Vec<u8>) -> Result<D, Error>

Produces asset data from given bytes. This method is a simplified version of format. This format assumes that the asset name is the full path and the asset is only contained in one file.

If you are implementing format yourself, this method will never be used and can be left unimplemented.

fn import(
    &self,
    name: String,
    source: Arc<dyn Source>,
    create_reload: Option<Box<dyn Format<D>>>
) -> Result<FormatValue<D>, Error>

Reads the given bytes and produces asset data.

You can implement import_simple instead of simpler formats.

Reload

The reload structure has metadata which allows the asset management to reload assets if necessary (for hot reloading). You should only create Reload when create_reload is Some. Also, the parameter is just a request, which means it's optional either way.

Loading content...

Implementations on Foreign Types

impl<D: 'static> Format<D> for Box<dyn Format<D>>[src]

impl<D: 'static> Format<D> for Box<dyn SerializableFormat<D>>[src]

Loading content...

Implementors

impl<D> Format<D> for RonFormat where
    D: for<'a> Deserialize<'a> + Send + Sync + 'static, 
[src]

Loading content...