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 + 'static>>;
// Required method
fn save(
&self,
writer: &mut Writer,
asset: SavedAsset<'_, Self::Asset>,
settings: &Self::Settings,
) -> impl ConditionalSendFuture<Output = Result<<Self::OutputLoader as AssetLoader>::Settings, Self::Error>>;
}
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.
This trait is generally used in concert with AssetWriter
to write assets as bytes.
For a complementary version of this trait that can load assets, see AssetLoader
.
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(
&self,
writer: &mut Writer,
asset: SavedAsset<'_, Self::Asset>,
settings: &Self::Settings,
) -> impl ConditionalSendFuture<Output = Result<<Self::OutputLoader as AssetLoader>::Settings, Self::Error>>
fn save( &self, writer: &mut Writer, asset: SavedAsset<'_, Self::Asset>, settings: &Self::Settings, ) -> impl ConditionalSendFuture<Output = Result<<Self::OutputLoader as AssetLoader>::Settings, Self::Error>>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.