Implement the stream port read callback for the dynamic_buffer_stream adapter.
This callback reads bytes from the adapter-managed in-memory dynamic buffer, starting at the current read cursor.
This function is a private backend callback bound into the dynamic_buffer_stream vtable. It implements the public behavior exposed through stream_read() for stream instances created by the dynamic_buffer_stream adapter.
See:
backend != NULL, backend must designate a valid dynamic_buffer_stream_t.backend == NULLbuf == NULL && n > 0n == 0:0.backend is left unchanged.st != NULL, *st is set to STREAM_STATUS_OK.0 < n and unread data is available:min(n, dbuf->len - dbuf->read_pos) bytes from the internal buffer starting at offset dbuf->read_pos.buf.dbuf->read_pos by the number of bytes returned.dbuf->len unchanged.st != NULL, *st is set to STREAM_STATUS_OK.0.st != NULL, *st is set to STREAM_STATUS_INVALID.If dbuf->read_pos >= dbuf->len:
0.backend unchanged.st != NULL, *st is set to STREAM_STATUS_EOF.backend is borrowed.buf is borrowed.n and the number of unread bytes remaining in the buffer.dbuf->len represents the number of valid bytes currently stored in the buffer.dbuf->read_pos represents the current read cursor within those valid bytes.