bevy_asset: Align asset path representation to a well-known specification by renaming label to fragment to improve code quality
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Introduction
bevy_asset uses the term `label` alongside `asset` and `path` (to be exact: `labeled_asset`, `AssetPath .label`).
Just as a path like `whatever/src/main.rs` locates a file in a file system, a label like `Scene0` is used to locate part of a file.
An asset in bevy can either be a file or part of a file.
How the label is used to locate the asset is up to the file type, its specifications and an accordingly implemented loader.
The location of an asset is represented as path and optional label: `path [ "#" label ]`
```
path/to/asset#label
\___________/ \___/
| |
path label
```
## What problem does this solve or what need does it fill?
Alignment to an established specification. Does more accurately convey the implementation.
## What solution would you like?
The representation already looks like parts of the URI.
URI is a specified, well-known standard to identify and locate (URL) resources. (note: URL is a specific URI, but the differences are negligible here)
An URI is defined as:
```
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
```
there also exists a file scheme for URI
```
file:///etc/fstab
\__/ | \_______/ | |
| | | | |
scheme authority path query fragment
```
Since bevy_asset already adheres to some specifications of the URI it makes sense to rename `label` to `fragment`.
In the context of location the asset is a `fragment` of a file. `label` does not convey being a detail of the asset location.
## What alternative(s) have you considered?
## Additional context
Completely adhering to the specification of URIs is unwanted and this issue does not aim to do so.
But, aligning the current implementation even more - meaning: adopting a scheme other than `file` would open up locations outside the fs. Assets could be served over `http(s)` by your workstation and streamed in by an end device with android or ios to enable hot-reloading for these devices. Whether this is needed or desired will be discussed in another issue, though.
Contributor guide
Research direction
Start in the bevy_asset code around AssetPath, labeled_asset, and the label-based path representation, then map all public and internal usages before changing terminology. Done means the representation and references consistently use fragment, with the project’s existing checks passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100