Skip to content

Possible to implement IoSafe for PipeReader / PipeWriter ? #232

@jk-ozlabs

Description

@jk-ozlabs

I'm looking to do async reads from a std::io::PipeReader:

let (reader, writer) = std::io::pipe()?;
let mut async_reader = smol::Async::new(reader)?;

However, std::io::PipeReader is not one of the IoSafe impls, so we don't have AsyncRead (and therefore AsyncReadExt) available.

It would be possible to add the impls in async-io:

 unsafe impl IoSafe for std::io::StderrLock<'_> {}
 unsafe impl IoSafe for std::io::StdinLock<'_> {}
 unsafe impl IoSafe for std::io::StdoutLock<'_> {}
+unsafe impl IoSafe for std::io::PipeReader {}
+unsafe impl IoSafe for std::io::PipeWriter {}
 unsafe impl IoSafe for std::net::TcpStream {}
 unsafe impl IoSafe for std::process::ChildStdin {}
 unsafe impl IoSafe for std::process::ChildStdout {}

However, this requires rust >= 1.87, for the introduction of PipeReader/PipeWriter, and I assume we're working with a MSRV of 1.63 at present.

Is there a conventional way to gate these on a cfg macro / build setting / something else?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions