Skip to content

Added io Module to bevy_platform_support #18353

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bushrat011899
Copy link
Contributor

Objective

Continuing no_std proliferation in Bevy is currently blocked on bevy_asset which makes extensive use of the standard library in two main areas:

  • std::io
  • std::path
    This is entirely sensible, since bevy_asset's primary job is to load assets from a path using filesystem IO.

However, assets can be used outside of strict IO operations. For example, users can manually add assets to an appropriate Assets<T> resource. Further, while Bevy supports std::path::Path, we have strong rules around what's considered canonical for an AssetPath; namely that platform specific behaviour (backslashes and drive letters on Windows for example) is not supported.

Since no_std support is likely to be highly disruptive in bevy_asset, this PR attempts to tackle a subset of the problem: independence from std::io::Result.

Solution

  • Created a new io module in bevy_platform_support which provides Error, Result, and ErrorKind.
  • When the standard library is not available, bevy_platform_support::io will fallback to an API compatible alternative.
  • Switch bevy_asset to use bevy_platform_support::io::Result. Since it is std::io::Result with the std feature enabled this is purely a path change and has no impact on API or functionality.

Testing

  • CI

Notes

  • It may be desirable to actually make a more breaking change to bevy_asset and instead roll its own AssetIoError type. However, this is likely more controversial so I have opted for this as a more gradual step.

@bushrat011899 bushrat011899 added this to the 0.17 milestone Mar 17, 2025
@bushrat011899 bushrat011899 added D-Trivial Nice and easy! A great choice to get started with Bevy A-Assets Load files from disk to use for things like images, models, and sounds C-Code-Quality A section of code that is hard to understand or change X-Controversial There is active debate or serious implications around merging this PR S-Needs-Review Needs reviewer attention (from anyone!) to move forward O-Embedded Weird hardware and no_std platforms labels Mar 17, 2025
@bushrat011899
Copy link
Contributor Author

Putting on the 0.17 milestone just to highlight I don't intend for this to land in 0.16. It could, but I'd rather not make that milestone harder to hit than it already is!

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-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy O-Embedded Weird hardware and no_std platforms S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant