allow::Ref
-based Allow API design.
#6
Draft
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.
Note: This is currently far from complete, just publishing so no-one else duplicates the effort I've already put into it.
This is attempt to resolve the last question from this comment: jrvanwhy#1 (comment)
The problem is that we want developers to be able to write APIs that can take both stack-allocated buffers and buffers from
.rodata
(and ideally.data
as well) without having to duplicate all their code. The idea is that APIs would take aPin<&mut allow::Ref<>>
:allow::Ref
can be constructed from a&'static [u8]
,&'static mut [u8]
,allow::Buffer
, etc. so APIs that accept anallow::Ref
can be used in several different contexts.Under this design, it will still be possible to use an
allow::Buffer
directly to perform Allow calls, as some API implementations (particularly those that only need small, fixed-size buffers) may choose to allocate their own buffers internally.