Trait bevy_internal::asset::saver::AssetSaver
source · pub trait AssetSaver: Send + Sync + 'static {
type Asset: Asset;
type Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>;
type OutputLoader: AssetLoader;
type Error: Into<Box<dyn Error + Send + Sync>>;
// Required method
fn save<'a>(
&'a self,
writer: &'a mut (dyn AsyncWrite + Send + Sync + Unpin + 'static),
asset: SavedAsset<'a, Self::Asset>,
settings: &'a Self::Settings
) -> Pin<Box<dyn Future<Output = Result<<Self::OutputLoader as AssetLoader>::Settings, Self::Error>> + Send + 'a>>;
}
Expand description
Saves an Asset
of a given AssetSaver::Asset
type. AssetSaver::OutputLoader
will then be used to load the saved asset
in the final deployed application. The saver should produce asset bytes in a format that AssetSaver::OutputLoader
can read.
Required Associated Types§
sourcetype Asset: Asset
type Asset: Asset
The top level Asset
saved by this AssetSaver
.
sourcetype Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>
type Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>
The settings type used by this AssetSaver
.
sourcetype OutputLoader: AssetLoader
type OutputLoader: AssetLoader
The type of AssetLoader
used to load this Asset
Required Methods§
sourcefn save<'a>(
&'a self,
writer: &'a mut (dyn AsyncWrite + Send + Sync + Unpin + 'static),
asset: SavedAsset<'a, Self::Asset>,
settings: &'a Self::Settings
) -> Pin<Box<dyn Future<Output = Result<<Self::OutputLoader as AssetLoader>::Settings, Self::Error>> + Send + 'a>>
fn save<'a>( &'a self, writer: &'a mut (dyn AsyncWrite + Send + Sync + Unpin + 'static), asset: SavedAsset<'a, Self::Asset>, settings: &'a Self::Settings ) -> Pin<Box<dyn Future<Output = Result<<Self::OutputLoader as AssetLoader>::Settings, Self::Error>> + Send + 'a>>
Saves the given runtime Asset
by writing it to a byte format using writer
. The passed in settings
can influence how the
asset
is saved.