-
Notifications
You must be signed in to change notification settings - Fork 285
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
Add support for zerocopy trait impls #738
Comments
The bytes crate is intended to never have a 2.0 release, so I'm reluctant to add new dependencies to the public API that don't have a similar guarantee. What guarantees are missing? We may be able to guarantee the missing guarantees. |
As an aside, it looks like the safety requirements of |
I have the same reservations as Alice. We've been very picky about adding any public dependencies. |
The main ones are the safety preconditions for
What do you mean by "not have the right value"? |
I mean that with the implementation in your prototype, calling |
Gotcha. That may be a non-starter then - we rely on the stability property to guarantee that if we first perform an alignment/size check and then split, the alignment and size will be the same after the split as before. It might be possible to work around (it would not be possible if you were saying that calling |
Mostly that if a split results in a 0-length slice of Line 138 in d7c1d65
|
We can probably change |
That'd be great if it's on the table! |
Is there anything else you need us to guarantee? |
It sounds like
|
That looks okay to me. |
Great! Then as soon as #740 is published on crates.io, we can add a feature to support bytes. |
An implementation is prototyped here.
The proposal is to implement zerocopy's
ByteSlice
andSplitByteSlice
traits for bytes'Bytes
andBytesMut
types, which will permit users to useBytes
andBytesMut
with zerocopy features as requested in google/zerocopy#1444.Note that it's not possible for zerocopy to add these impls itself since the traits have safety invariants which are not guaranteed by
Bytes
andBytesMut
's public documentation - it's only possible to prove that these impls are correct inside of bytes itself.The text was updated successfully, but these errors were encountered: