I'm porting a "MultiplexingStream" library that I already have in .NET and Node.js to a rust crate.
One important feature of this library relates to backpressure. The network protocol requires that I inform the remote party when the local party has processed some bytes that the remote party previously sent, to manage the 'receiving window size' so the sender doesn't send data faster than the receiver can process.
All of this is distinctly written with APIs such that the two parties may be in the same process or across a network. So I've been using DuplexStream
for this so far.
But DuplexStream appears to have no API to notify or observe when data is read from the DuplexStream so that I can track how much data is currently in the buffer going a particular direction.
Am I missing something? Is there another API that does offer notifications for every read operation?