+/** @brief State structure for a buffered reader */
+struct ev_reader {
+ /** @brief Input buffer */
+ struct buffer b;
+ /** @brief File descriptor read from */
+ int fd;
+ /** @brief Called when new data is available */
+ ev_reader_callback *callback;
+ /** @brief Called on error and shutdown */
+ ev_error_callback *error_callback;
+ /** @brief Passed to @p callback and @p error_callback */
+ void *u;
+ /** @brief Parent event loop */
+ ev_source *ev;
+ /** @brief Set when EOF is detected */
+ int eof;
+ /** @brief Error code to pass to error callback */
+ int error;
+ /** @brief Tied writer or NULL */
+ ev_writer *writer;
+};
+
+/* buffered writer ************************************************************/
+
+/** @brief Shut down the writer
+ *
+ * This is called to shut down a writer. The error callback is not called
+ * through any other path. Also we do not cancel @p fd from anywhere else,
+ * though we might disable it.
+ *
+ * It has the signature of a timeout callback so that it can be called from a
+ * time=0 timeout.