Skip to content

Conversation

@andriyDev
Copy link
Contributor

@andriyDev andriyDev commented Dec 13, 2025

Objective

Solution

  • Allow AssetLoader to say which "features" of a reader it needs.
  • Pass that list of features to AssetReader so it can decide how to handle it.
  • Add a new AssetReaderError::UnsupportedFeature.

This design is kind of "weak" - there's no guarantee that a loader that requests AnySeek will get a reader that actually implements AsyncSeek. Or on the other side, there's no guarantee that a loader actually requests the features that it uses. However, in practice it's likely enough: errors are likely to guide users to the correct situation. In the future, we could perhaps have a "sieve reader", which blocks any features the loader didn't explicitly request. Perhaps this is a debug only feature, or something that can be toggled.

Testing

  • Ran the modified examples. They still seem to work!

@andriyDev andriyDev added C-Feature A new feature, making something new possible A-Assets Load files from disk to use for things like images, models, and sounds M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide M-Release-Note Work that should be called out in the blog due to impact D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 13, 2025
@andriyDev andriyDev force-pushed the seek branch 3 times, most recently from f515166 to 8c5977d Compare December 13, 2025 08:39
@@ -1,3 +1,5 @@
#[cfg(feature = "trace")]
use crate::io::ReaderRequiredFeatures;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this could be in the #[cfg(feature = "trace")] use { block below

Copy link
Contributor

@atlv24 atlv24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice job, looks good to me

Comment on lines +230 to +233
fn reader_required_features(
&self,
settings: &dyn Settings,
) -> Result<ReaderRequiredFeatures, ProcessError>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this have a default implementation? That would remove a bunch of boilerplate.

@janhohenheim janhohenheim added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Assets Load files from disk to use for things like images, models, and sounds C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AsyncSeek trait bound on Reader may limit options to stream bytes

4 participants