TL;DR
What are the design decisions behind having poll_close in AsyncWrite and not in a separate trait like AsyncClose? I'm wondering because close is not part of std::io::Write which does not mandate making closing explicit and allows "close on drop" like std::fs::File
Background Story
First and foremost, thank you very much for this crate! We are currently evaluating adding async support to serialport-rs with futures-rs and I really like how this bridges to smol and tokio which we use as initial targets for our PoC.
Today, I started the discussion on why the async variant of a serial port needs to be closable where the already existing sync variant handles this as "close on drop" like for example std::io::File. I learned that closing is part of AsyncWrite which requires to deal with the concept of closing in the async serial port as well.
Having only little work done with async I/O, smol, and tokio so far, I would have it expected to be separate from AsyncWrite. The AsyncRead trait does not support closing and so I would naively have it expected in a trait like AsyncClose. The latter would have allowed to keep the async variant of a serialport "close on drop" as well. So I'm really wondering and interested in the design decisions behind having poll_close in AsyncWrite?
TL;DR
What are the design decisions behind having
poll_closeinAsyncWriteand not in a separate trait likeAsyncClose? I'm wondering because close is not part ofstd::io::Writewhich does not mandate making closing explicit and allows "close on drop" likestd::fs::FileBackground Story
First and foremost, thank you very much for this crate! We are currently evaluating adding async support to serialport-rs with futures-rs and I really like how this bridges to smol and tokio which we use as initial targets for our PoC.
Today, I started the discussion on why the async variant of a serial port needs to be closable where the already existing sync variant handles this as "close on drop" like for example
std::io::File. I learned that closing is part ofAsyncWritewhich requires to deal with the concept of closing in the async serial port as well.Having only little work done with async I/O, smol, and tokio so far, I would have it expected to be separate from
AsyncWrite. TheAsyncReadtrait does not support closing and so I would naively have it expected in a trait likeAsyncClose. The latter would have allowed to keep the async variant of a serialport "close on drop" as well. So I'm really wondering and interested in the design decisions behind havingpoll_closeinAsyncWrite?