-
Notifications
You must be signed in to change notification settings - Fork 155
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
zerocopy
support
#687
Comments
The zerocopy crate can't be used as dependency of libstd as it doesn't have the rustc-dep-of-std hack. Libstd depends on object through the backtrace crate. As any zerocopy integration has to be optional. |
Some information on the rustc-dep-of-std hack, since I didn't know about it before: rust-lang/wg-cargo-std-aware#51. |
The Can you give an example of what adding I have looked at both |
Ah, that sucks. :(
Using the crate's structs in my own zero-copy-derived structs, with safety guaranteed by zerocopy.
I wasn't aware of |
Ok, but the safety can't be guaranteed because the derive doesn't support this crate's structs (unless it has changed since I last looked). So is there still any value to this?
We would still need to define our own endianness types, whether we use |
The safety can be guaranteed for my own crate when I use zerocopy, since I don't use generic endianness there. It seems that use zerocopy::ByteOrder;
use zerocopy::U64;
use zerocopy_derive::AsBytes;
#[derive(AsBytes)]
#[repr(packed)]
struct Struct<O: ByteOrder> {
integer: U64<O>,
}
Ah, the |
So you're not using this crate's structs in your own zero-copy-derived structs then. To be clear, it's going to be a high bar to add support here. You'll need to give a code example of what it allows you to do. Simply avoiding importing another trait in your crate isn't enough.
Yes. |
Yes, I currently can't derive zerocopy's traits because this crate doesn't implement them on its types. This is basically the reason for this feature request.
Makes sense. Since I don't have a finished crate, I'll close this feature request. I'll come back if I ever finish this project. |
Also object can't make use of the zerocopy derive macros anyway as libstd can't (directly or indirectly) depend on any proc macro without breaking cross compilation support. |
I'm already using Google's
zerocopy
in my crate and want to start usingobject
. Would a PR adding support forzerocopy
bee accepted? Theoretically, the wholepod
module could also be replaced by it.The text was updated successfully, but these errors were encountered: