-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking Issue for Read::is_read_vectored/Write::is_write_vectored. #69941
Comments
Is there a situation under which this would not be better off as an associated constant? |
Those are not compatible with trait objects. |
Is this a design choice, or just something that has not been implemented yet? |
That is inherent to how constants work. |
#105917 is an interesting case to think about: io::Chain. When chaining one stream that is write vectored with another one that isn't, io::Chain::is_write_vectored could make its return value depend on whether it's currently in the first or second stream, I suppose. (Not saying that it should. But we should probably document what is expected.) |
Is there a timeline to stabilize this feature? Knowing whether a socket supports vectored I/O or not gives applications a bunch of optimization opportunities :) |
As one potential argument for the acceptance of As @xiaoyawei noted, it would be especially nice to be able to detect support for vectored writes on stable. In an experimental branch of the pub async fn write_async<T: io::AsyncWrite>(&self, mut writer: Pin<&mut T>) -> ZipResult<()> {
let block: [u8; 22] = unsafe {
mem::transmute(CentralDirectoryEndBuffer {
magic: CENTRAL_DIRECTORY_END_SIGNATURE,
disk_number: self.disk_number,
disk_with_central_directory: self.disk_with_central_directory,
number_of_files_on_this_disk: self.number_of_files_on_this_disk,
number_of_files: self.number_of_files,
central_directory_size: self.central_directory_size,
central_directory_offset: self.central_directory_offset,
zip_file_comment_length: self.zip_file_comment.len() as u16,
})
};
if writer.is_write_vectored() {
/* TODO: zero-copy!! */
let block = IoSlice::new(&block);
let comment = IoSlice::new(&self.zip_file_comment);
writer.write_vectored(&[block, comment]).await?;
} else {
/* If no special vector write support, just perform two separate writes. */
writer.write_all(&block).await?;
writer.write_all(&self.zip_file_comment).await?;
}
Ok(())
}
} I suppose it's true that I could have done this without checking However, I'm now also realizing that the above code is probably incorrect, as I don't check whether tokio's async Regarding @m-ou-se's comment on
@workingjubilee's proposal at https://github.com/rust-lang/rust/pull/105917/files#r1278629167 to make Thanks so much for reading, I really appreciate your work. |
Unresolved Questions
Implementation history
The text was updated successfully, but these errors were encountered: