Skip to main content

qubit_io/
lib.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8
9//! # Qubit IO
10//!
11//! Unit-oriented buffering and small I/O trait utilities for Rust.
12//!
13//! This crate provides named, object-safe composition traits for common
14//! [`std::io`] capability combinations and small extension traits for recurring
15//! standard-library I/O patterns.
16//!
17//! It also provides item-oriented buffering primitives in [`buffered`]:
18//! [`Buffer`], [`BufferedInput`], [`BufferedOutput`],
19//! [`EnsuredBufferedInput`], and [`EnsuredBufferedOutput`]. These types are
20//! intentionally format-agnostic. Binary and text stream adapters live in
21//! sibling crates and build their codec-specific behavior on top of these item
22//! windows.
23//!
24//! The concrete trait definitions and wrapper types live in dedicated modules
25//! and are re-exported from the crate root for ergonomic use.
26// qubit-style: allow coverage-cfg
27
28pub mod buffered;
29mod capacity_const;
30pub mod ext;
31mod traits;
32mod util;
33mod wrappers;
34
35pub use buffered::{
36    Buffer,
37    BufferedInput,
38    BufferedOutput,
39    EnsuredBufferedInput,
40    EnsuredBufferedOutput,
41};
42pub use capacity_const::{
43    DEFAULT_BUFFER_CAPACITY,
44    DEFAULT_COMPARE_BUFFER_SIZE,
45    DEFAULT_COPY_BUFFER_SIZE,
46};
47pub use ext::{
48    BufReadExt,
49    ReadExt,
50    ReadSeekExt,
51    SeekExt,
52    WriteExt,
53    WriteSeekExt,
54};
55pub use traits::{
56    BufReadSeek,
57    Input,
58    Output,
59    ReadSeek,
60    ReadWrite,
61    ReadWriteSeek,
62    Seekable,
63    SeekableInput,
64    SeekableOutput,
65    WriteSeek,
66};
67pub use util::Streams;
68#[allow(unused_imports)]
69pub use util::UncheckedSlice;
70#[cfg(coverage)]
71#[doc(hidden)]
72pub use util::{
73    coverage_add_item_count_overflow,
74    coverage_fail_next_add_item_count,
75    coverage_fail_next_reserve,
76    coverage_fail_next_string_reserve,
77    coverage_fail_reserve_after,
78    coverage_reset_add_item_count_hooks,
79    coverage_reset_reserve_hooks,
80};
81#[allow(unused_imports)]
82pub use util::{
83    nz,
84    nz_const,
85};
86pub use util::{
87    try_reserve_string,
88    try_reserve_vec,
89};
90pub use wrappers::{
91    ChecksumReader,
92    ChecksumWriter,
93    CountingReader,
94    CountingWriter,
95    LimitReader,
96    LimitWriter,
97    PositionGuard,
98    SyncSeekTeeReader,
99    TeeReader,
100    TeeWriter,
101};