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
53
54
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
use crateByteOutput;
use crateSeekableOutput;
/// A synchronous output that transfers and seeks in bytes.
///
/// This trait adds no methods. Every [`SeekableOutput`] with both
/// `Item = u8` and `Unit = u8`, including unsized streams, implements it
/// automatically. Implement the underlying output and seek traits instead.
///
/// # Examples
///
/// ```
/// use std::io::{Result, SeekFrom};
/// use qubit_io::SeekableByteOutput;
///
/// fn rewind(stream: &mut dyn SeekableByteOutput) -> Result<u64> {
/// stream.seek_to(SeekFrom::Start(0))
/// }
/// ```
///
/// Streams with a different item type do not satisfy this bound:
///
/// ```compile_fail
/// use qubit_io::{SeekableByteOutput, SeekableOutput};
///
/// fn accept(stream: impl SeekableByteOutput) {}
///
/// fn reject(stream: impl SeekableOutput<Item = char, Unit = char>) {
/// accept(stream);
/// }
/// ```
///
/// The seek unit must also match the transferred items:
///
/// ```compile_fail
/// use qubit_io::{Output, Seekable, SeekableByteOutput};
///
/// fn accept(stream: impl SeekableByteOutput) {}
///
/// fn reject(stream: impl Output<Item = u8> + Seekable<Unit = char>) {
/// accept(stream);
/// }
/// ```