Add getters and From
implementations to BufferSlice
.
#7148
Merged
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.
Connections
Part of addressing #6974
Description
This PR adds functions to make
BufferSlice
usable in more situations.BufferSlice::buffer()
,BufferSlice::offset()
andBufferSlice::size()
allow decomposing aBufferSlice
. This allows a function which receives aBufferSlice
to use it, for example, in texture copy operations. I'd like to have a more ergonomic interface to that, but I haven’t thought of one; adding these getters ensures that there is never any unavoidable inexpressiveness. However,BufferSlice
to itsBuffer
and accessing data outside the slice. I think that this is worth considering, but that on net it is more important to be flexible than to be strict, here, particularly as buffers are interior mutable and clonable so there is no fundamental mutability-xor-sharing like&mut [u8]
would have.BufferSlice::size()
returns aBufferSize
rather than anOption<BufferSize>
. See Refactor: eliminate unnecessaryOption<BufferSize>
#7147 for context on why I think this is the right choice — theOption
should, I think, be considered an obsolete implementation detail.impl From<BufferSlice> for BufferBinding
impl From<BufferSlice> for BindingResource
Please merge this PR without squashing; the commits are self-contained.
Testing
Added and ran API tests.
Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.