Skip to content

Need an interface to plug asynchronous Windows Handle types for serial ports #3396

@jadamcrain

Description

@jadamcrain

Is your feature request related to a problem? Please describe.
In Tokio 0.2, PollEvented was used in tokio-serial to make serial ports work asynchronously with Tokio.

Tokio 0.3/1.0 have removed all the mio types, and exposed only a unix-specifix AsyncFd type. So serial ports can be integrated asynchrnously on Linux, but not windows.

Describe the solution you'd like
I'd like to see a parallel API to AsyncFd which is Windows-only allowing a windows Handle type to be registered.

To register a handle, I personally only need a single public method:

pub fn register<H, R >(inner: H) -> tokio::io::Result<R> where H: std::os::windows::io::AsRawHandle, R: AsyncRead + AsyncWrite + Unpin

Describe alternatives you've considered

I've considered running serial ports synchronously, after all there aren't 10K of them, but we are writing protocol libraries for SCADA systems using Tokio where the same protocol is used over TCP or serial. Our codebase uses generic fucntionality based on AsyncRead + AsyncWrite so this not tenable for us because our entire protocol stack is async.

I've also considered having my Windows serial port implementation fake async by delegating blocking operations to a dedicated thread, but this is not optimal in the long run.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateC-feature-requestCategory: A feature request.M-ioModule: tokio/ioM-netModule: tokio/net

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions