Added io
Module to bevy_platform_support
#18353
Open
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.
Objective
Continuing
no_std
proliferation in Bevy is currently blocked onbevy_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 supportsstd::path::Path
, we have strong rules around what's considered canonical for anAssetPath
; 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 inbevy_asset
, this PR attempts to tackle a subset of the problem: independence fromstd::io::Result
.Solution
io
module inbevy_platform_support
which providesError
,Result
, andErrorKind
.bevy_platform_support::io
will fallback to an API compatible alternative.bevy_asset
to usebevy_platform_support::io::Result
. Since it isstd::io::Result
with thestd
feature enabled this is purely a path change and has no impact on API or functionality.Testing
Notes
bevy_asset
and instead roll its ownAssetIoError
type. However, this is likely more controversial so I have opted for this as a more gradual step.