Skip to content
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

Lower level io methods for AssetServer. #13493

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mintlu8
Copy link
Contributor

@mintlu8 mintlu8 commented May 24, 2024

Objective

Grant async code platform agnostic file system access to the assets folder and other AssetSources through AssetServer.

Solution

Added async methods read_stream and write_stream that can be used to read and write files as bytes or into an AsyncRead/AsyncWrite.

Example

async {
    let mut buffer = Vec::new();
    // Loads "assets/configs/config.toml"
    asset_server.read_stream("configs/config.toml", &mut buffer).await?;
    let config = toml::from_bytes(&buffer)?;
}

Testing

Added a test case for AssetServer

Issue: We currently have no tests for AssetWriter so the write function is untested. Adding testing support for AssetWriters would require a more dedicated PR.

Changelog

  • Added read_stream and write_stream to AssetServer.

@alice-i-cecile alice-i-cecile added C-Enhancement A new feature A-Assets Load files from disk to use for things like images, models, and sounds C-Needs-Release-Note Work that should be called out in the blog due to impact S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged D-Async Deals with asynchronous abstractions D-Domain-Agnostic Can be tackled by anyone with generic programming or Rust skills labels May 24, 2024
@mintlu8 mintlu8 marked this pull request as ready for review May 28, 2024 19:07
@mintlu8
Copy link
Contributor Author

mintlu8 commented May 29, 2024

Writer testing is blocked on #13406.

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-Enhancement A new feature C-Needs-Release-Note Work that should be called out in the blog due to impact D-Async Deals with asynchronous abstractions D-Domain-Agnostic Can be tackled by anyone with generic programming or Rust skills S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants