Skip to content
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

Interface::bulk_out() - support also slices as an argument #61

Open
XVilka opened this issue Jun 24, 2024 · 1 comment
Open

Interface::bulk_out() - support also slices as an argument #61

XVilka opened this issue Jun 24, 2024 · 1 comment

Comments

@XVilka
Copy link

XVilka commented Jun 24, 2024

Currently, the method signature is

pub fn bulk_out(&self, endpoint: u8, buf: Vec<u8>)

But it makes a requirement to allocate the buf, which isn't always welcome. I suggest also to support specifying buf as &[u8] slice.

@kevinmehall
Copy link
Owner

Unfortunately an API taking a borrowed slice is not safe when it comes to async IO in Rust, because you can leak the Future and regain mutable access to the buffer while the kernel continues to read from it. It's the same problem as io-uring and other completion-based IO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants