buffer

This sink's internal buffer. It contains data written to the sink, but not yet flushed to the upstream.

Incorrect use of the buffer may cause data loss or unexpected data being sent to the upstream. Consider using alternative APIs to write data into the sink, if possible:

  • write data into separate Buffer instance and write that buffer into the sink and then flush the sink to ensure that the upstream will receive complete data;

  • implement RawSink and wrap an upstream sink into it to intercept data being written.

If there is an actual need to write data directly into the buffer, consider using Sink.writeToInternalBuffer instead.