Skip to content

Why are buffers passed by value and not by reference #311

Answered by NobodyXu
tidely asked this question in Q&A
Discussion options

You must be logged in to vote

I feel like from a ownership perspective a &mut Vec<u8> would still work, without taking the cancel-lability into account.

It won't work as it has to be owned.

Future in rust isn't guaranteed to be polled to end, nor is it guaranteed to be dropped.

Potential solution could be:

  • introduce async future that must be polled to end (cannot be cancelled)
  • introduce async drop and guarantee that some types must be dropped (otherwise it could leak).
  • introduce linear type

I did see that for the 6.12 kernel there is a patch to add async discard to io_uring, which could potentially provide a solution?

I believe that's for the SSD discard via ioctl.

Io-uring already supports cancelling an in-flig…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@tidely
Comment options

@NobodyXu
Comment options

Answer selected by tidely
@tidely
Comment options

@NobodyXu
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants