Open psychon opened 4 years ago
Changing the public API from &[]
to &mut []
is easy. Using this change in RustConnection::write_all_vectored
then runs into lifetime problems. Oh and compute_length_field
also ended up with lifetime problems. Someone who understands covariance and invariance may give this a shot.
Part of the problem is that I do not see how to implement https://doc.rust-lang.org/std/io/struct.IoSlice.html#method.advance on stable without unsafe code. When you have a &'b IoSlice<'a>
, you can only get an &'b [u8]
, but would need an &'a [u8]
to implement advance()
.
I created the advance
crate as an "unsafe-quarantine microcrate" to allow for usage of the advance
function in stable environments. Using that, we could probably resolve this issue.
IoSlice::advance
will be stabilized in Rust 1.81
XCBConnection
creates a copy of the passed in slice of request buffers. So far,RustConnection
does not, but instead switches betweenwrite_vectored
and plainwrite
for a buffer: https://github.com/psychon/x11rb/blob/314242b7fcdee3f3603010ca22c79f89793d5629/src/rust_connection/mod.rs#L682-L683I think it should be possible to get rid of that
write
part by using a mutable slice for request sending. That way, partial writes can be done by replacing the respectiveIoSlice
.