compress: cstream: add support for temporarily moving the cursor and performing limited i/o operations

the cursor can only be moved during uncompressed i/o, and any read/write operations are performed directly on the underlying endpoint with no buffering, and don't count towards the transacted byte statistics.

the cursor can only be moved once, after which it's position must be restored.
This commit is contained in:
2025-07-31 11:18:10 +01:00
parent 10dfa54d5c
commit ede5e72fc2
3 changed files with 83 additions and 0 deletions

View File

@@ -8,7 +8,12 @@
struct b_stream;
struct b_compressor;
enum cstream_flags {
CSTREAM_CURSOR_MOVED = 0x01u,
};
struct b_cstream {
enum cstream_flags s_flags;
struct b_stream *s_endpoint;
struct b_compressor *s_compressor;
/* s_in is the input buffer, and s_out is the output buffer.
@@ -55,6 +60,10 @@ struct b_cstream {
* b_cstream_read
*/
size_t s_tx_uncompressed_bytes;
/* when the endpoint cursor is moved, the previous cursor position is
* saved here so it can be restored later */
size_t s_cursor;
};
#endif