-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Body
can be limiting.
#963
Comments
The body needs to be static, because it might (and in case of Casting a buffer to a static slice could be very dangerous. Is the FFI caller giving you ownership of the buffer? |
Thats why I'm trying to avoid it.
No, let me illustrate my problem: struct Buffer {
data: *const u8
len: usize
}
impl AsRef<[u8]> for Buffer { ... }
impl Drop for Buffer {
fn drop(&mut self) {
unsafe { ffi::free(self.data) }
}
} This |
Are you using the blocking client? If so, you can use |
I just switched from the blocking one to the async one because my workload demanded it, before that I was using exactly that solution. |
In that case, probably the best thing would be for us to make the |
Mh, I didn't even know I will look into the |
Here is my little experiment. |
I was just looking into the vtable stuff, that would definitly be fixing the problem right at the source, instead of exposing a new API in reqwest. So I assume the related issue is: tokio-rs/bytes#359? |
I have a use case where I get a
&[u8]
over FFI that I want to use as a body to send a request with.The issue arises because I can't take ownership of it in Rust because it can't be deallocated in Rust and has to be deallocated over FFI. So the only solution is to convert it to a
&'static [u8]
via unsafe and make sure nothing goes wrong.I was thinking that one simple solution might just be to enable
Body
to take anyT
that implementsAsRef<[u8]>
for example. That way thatT
can implement it's ownDrop
that deallocates properly over FFI.Is this appropriate/in scope? Are there alternatives?
The text was updated successfully, but these errors were encountered: