1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*******************************************************************************
*
* Copyright (c) 2026 Haixing Hu.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0.
*
******************************************************************************/
use ;
/// Object-safe capability trait for values that can be read, written, and
/// repositioned.
///
/// `ReadWriteSeek` gives the common [`Read`] + [`Write`] + [`Seek`] combination
/// a named trait for APIs that need full mutable random-access I/O through a
/// trait object. Typical use cases include in-place file updates, editable
/// binary containers, test buffers, and components that should accept either a
/// file-like handle or an in-memory cursor.
///
/// The trait adds no methods of its own. All operations come from the
/// standard-library supertraits, and every type implementing [`Read`],
/// [`Write`], and [`Seek`] automatically implements `ReadWriteSeek`.
///
/// # Examples
///
/// ```rust
/// use qubit_io::ReadWriteSeek;
/// use std::io::SeekFrom;
///
/// fn rewrite_first_byte(io: &mut dyn ReadWriteSeek) -> std::io::Result<String> {
/// io.write_all(b"abc")?;
/// io.seek(SeekFrom::Start(0))?;
/// io.write_all(b"z")?;
/// io.seek(SeekFrom::Start(0))?;
///
/// let mut output = String::new();
/// io.read_to_string(&mut output)?;
/// Ok(output)
/// }
///
/// let mut cursor = std::io::Cursor::new(Vec::new());
/// assert_eq!(rewrite_first_byte(&mut cursor)?, "zbc");
/// # Ok::<(), std::io::Error>(())
/// ```