-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssetSaver and AssetTransformer split #11260
Merged
alice-i-cecile
merged 6 commits into
bevyengine:main
from
thepackett:saver-processor-split
Jan 26, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2686914
Implemented AssetTransformer and LoadTransformAndSave. Removed LoadAn…
thepackett bbadb2d
Double PhantomData fix
thepackett da4dd47
Fixed broken doc links
thepackett 4a19dd6
Readded LoadAndSave. Removed accidental unfinished example comment.
thepackett 7565868
Removed experimental Noop AssetTransformer implementation.
thepackett 74d0891
Reorganized file. Added missing documentation.
thepackett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::{meta::Settings, Asset}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Transforms an [`Asset`] of a given [`AssetTransformer::AssetInput`] type to an [`Asset`] of [`AssetTransformer::AssetOutput`] type. | ||
pub trait AssetTransformer: Send + Sync + 'static { | ||
/// The [`Asset`] type which this [`AssetTransformer`] takes as and input. | ||
type AssetInput: Asset; | ||
/// The [`Asset`] type which this [`AssetTransformer`] outputs. | ||
type AssetOutput: Asset; | ||
/// The settings type used by this [`AssetTransformer`]. | ||
type Settings: Settings + Default + Serialize + for<'a> Deserialize<'a>; | ||
/// The type of [error](`std::error::Error`) which could be encountered by this saver. | ||
type Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>; | ||
|
||
fn transform<'a>( | ||
&'a self, | ||
asset: Self::AssetInput, | ||
settings: &'a Self::Settings, | ||
) -> Result<Self::AssetOutput, Box<dyn std::error::Error + Send + Sync + 'static>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
( | ||
meta_format_version: "1.0", | ||
asset: Process( | ||
processor: "bevy_asset::processor::process::LoadAndSave<asset_processing::CoolTextLoader, asset_processing::CoolTextSaver>", | ||
processor: "bevy_asset::processor::process::LoadTransformAndSave<asset_processing::CoolTextLoader, asset_processing::CoolTextTransformer, asset_processing::CoolTextSaver>", | ||
settings: ( | ||
loader_settings: (), | ||
saver_settings: ( | ||
transformer_settings: ( | ||
appended: "X", | ||
), | ||
saver_settings: (), | ||
), | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
( | ||
meta_format_version: "1.0", | ||
asset: Process( | ||
processor: "bevy_asset::processor::process::LoadAndSave<asset_processing::CoolTextLoader, asset_processing::CoolTextSaver>", | ||
processor: "bevy_asset::processor::process::LoadTransformAndSave<asset_processing::CoolTextLoader, asset_processing::CoolTextTransformer, asset_processing::CoolTextSaver>", | ||
settings: ( | ||
loader_settings: (), | ||
saver_settings: ( | ||
transformer_settings: ( | ||
appended: "", | ||
), | ||
saver_settings: (), | ||
), | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
( | ||
meta_format_version: "1.0", | ||
asset: Process( | ||
processor: "bevy_asset::processor::process::LoadAndSave<asset_processing::CoolTextLoader, asset_processing::CoolTextSaver>", | ||
processor: "bevy_asset::processor::process::LoadTransformAndSave<asset_processing::CoolTextLoader, asset_processing::CoolTextTransformer, asset_processing::CoolTextSaver>", | ||
settings: ( | ||
loader_settings: (), | ||
saver_settings: ( | ||
transformer_settings: ( | ||
appended: "", | ||
), | ||
saver_settings: (), | ||
), | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
( | ||
meta_format_version: "1.0", | ||
asset: Process( | ||
processor: "bevy_asset::processor::process::LoadAndSave<asset_processing::CoolTextLoader, asset_processing::CoolTextSaver>", | ||
processor: "bevy_asset::processor::process::LoadTransformAndSave<asset_processing::CoolTextLoader, asset_processing::CoolTextTransformer, asset_processing::CoolTextSaver>", | ||
settings: ( | ||
loader_settings: (), | ||
saver_settings: ( | ||
transformer_settings: ( | ||
appended: "", | ||
), | ||
saver_settings: (), | ||
), | ||
), | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not have to constrain the loader type, or the transformer output here? Huh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following. Does:
need further constraints?
L
can be anyAssetLoader
,T
can be anyAssetTransformer
that acceptsL
's output as an input, andS
can by anyAssetSaver
that acceptsT
's output as an input.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a second look I guess it makes sense. I'm a bit surprised we don't have to specify e.g. the AssetTransformer output type, but it does make sense as is.