Skip to content

Add AsyncRead::poll_read_buf based on RFC 2930 #2209

Open
@taiki-e

Description

@taiki-e

Add the poll_read_buf method to AsyncRead based on the API proposed by rust-lang/rfcs#2930 (tracking issue: rust-lang/rust#78485).

pub trait AsyncRead {
    fn poll_read_buf(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<io::Result<()>>;
}

pub struct ReadBuf<'a> {
    buf: &'a mut [MaybeUninit<u8>],
    filled: usize,
    initialized: usize,
}

impl<'a> ReadBuf<'a> {
   // ...
}

This replaces the existing read-initializer API, but it's not yet stable, so maybe it needs to added as an unstable feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions