- -- | Flush all the data from the supplied write buffer out to the device
- flushWriteBuffer :: dev -> Buffer Word8 -> IO ()
+ -- | Prepares an empty write buffer. This lets the device decide
+ -- how to set up a write buffer: the buffer may need to point to a
+ -- specific location in memory, for example. This is typically used
+ -- by the client when switching from reading to writing on a
+ -- buffered read/write device.
+ --
+ -- There is no corresponding operation for read buffers, because before
+ -- reading the client will always call 'fillReadBuffer'.
+ emptyWriteBuffer :: dev -> Buffer Word8 -> IO (Buffer Word8)
+ emptyWriteBuffer _dev buf
+ = return buf{ bufL=0, bufR=0, bufState = WriteBuffer }
+
+ -- | Flush all the data from the supplied write buffer out to the device.
+ -- The returned buffer should be empty, and ready for writing.
+ flushWriteBuffer :: dev -> Buffer Word8 -> IO (Buffer Word8)