-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a poll variant to
DmaStreamReader::get_buffer_aligned
Since `DmaStreamReader` is a stream, we have to play well with other streams and make our functions easy to use from a polling context. `get_buffer_aligned` is an async function and, as such, is hard to use from there (not impossible, just hard). If we look at the `AsyncRead` trait, one may see that it defines only poll functions. Async functions are then built on top in the `AsyncReadExt.` This is done because creating a future from a poll function is trivial, while the other way around is hard. Therefore, we create a new function `poll_get_buffer_aligned` and we reimplement `get_buffer_aligned` as a wrapper around it: ```rust pub async fn get_buffer_aligned(&mut self, len: u64) -> Result<ReadResult> { poll_fn(|cx| self.poll_get_buffer_aligned(cx, len)).await } ```
- Loading branch information
Showing
1 changed file
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters