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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! # multiio
//!
//! A unified I/O orchestration library for CLI and server applications.
//!
//! ## Overview
//!
//! multiio provides:
//! - **Multi-input/Multi-output**: Read from and write to multiple sources simultaneously
//! - **Format abstraction**: Built-in support for JSON, YAML, CSV, XML, and plaintext
//! - **Extensible formats**: Implement the `Format` trait for custom formats
//! - **Sync and Async**: Both synchronous and asynchronous I/O support
//! - **Error handling**: Configurable error policies (FastFail or Accumulate)
//! - **Pipeline configuration**: Define I/O workflows via YAML/JSON config files
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use multiio::{MultiioBuilder, error::ErrorPolicy};
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Debug, Deserialize, Serialize)]
//! struct Config {
//! name: String,
//! value: i32,
//! }
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let engine = MultiioBuilder::default()
//! .add_input("config.json")
//! .add_output("-") // stdout
//! .with_mode(ErrorPolicy::FastFail)
//! .build()?;
//!
//! let configs: Vec<Config> = engine.read_all()?;
//! engine.write_all(&configs)?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Features
//!
//! - `json` - JSON format support (enabled by default)
//! - `yaml` - YAML format support (enabled by default)
//! - `csv` - CSV format support (enabled by default)
//! - `xml` - XML format support
//! - `plaintext` - Plaintext format support (enabled by default)
//! - `async` - Async I/O support with Tokio
//! - `miette` - Pretty error reporting with miette
//!
//! ## Streaming usage & semantics
//!
//! multiio provides streaming deserialization for several formats.
//!
//! - **Sync streaming helpers** (in `multiio::format`):
//! - `deserialize_json_stream` – NDJSON / multi-document JSON (`Read` -> `Iterator`)
//! - `deserialize_csv_stream` – row-by-row CSV records
//! - `deserialize_yaml_stream` – multi-document YAML
//! - `deserialize_plaintext_stream` – line-based plaintext
//! - **Sync engine streaming**:
//! - `IoEngine::read_records<T>()` uses `FormatRegistry::stream_deserialize_into` to
//! pick the right streaming implementation (including custom formats). Each record
//! is yielded as `Result<T, SingleIoError>`.
//! - **Memory model (sync)**:
//! - Streaming helpers work directly from a `Read` implementation and do not require
//! loading the entire input into memory at once, aside from what the underlying
//! decoder (e.g. `serde_json`, `csv`, `serde_yaml`) buffers internally.
//!
//! - **Async engine streaming**:
//! - `AsyncIoEngine::read_records_async<T>(concurrency)` reads each async input into
//! a `Vec<u8>` and then reuses the same sync streaming helpers via an in-memory
//! cursor. This gives record-level streaming semantics on top of an async source,
//! while keeping the implementation simple and predictable.
//! - `concurrency` controls how many inputs are processed in parallel; records from
//! different inputs may be interleaved in the resulting stream.
//! - **Memory model (async)**:
//! - Because each input is first read into a `Vec<u8>`, the peak memory usage per
//! input is still proportional to the full input size. Streaming at the record
//! level improves processing behavior, but does not yet provide true incremental
//! I/O at the byte level.
//!
//! - **YAML async streaming note**:
//! - Synchronous YAML streaming (`deserialize_yaml_stream`) yields documents lazily
//! from a reader.
//! - In the async engine, YAML streaming currently collects all documents from a
//! reader into an in-memory `Vec` before exposing them as a record stream. This
//! avoids Send-related limitations in the underlying `serde_yaml` streaming
//! implementation, at the cost of higher temporary memory usage for very large
//! YAML streams.
// Core modules
// Async modules (feature-gated)
// Re-exports for convenience
pub use MultiioBuilder;
pub use ;
pub use IoEngine;
pub use ;
pub use CustomFormat;
pub use ;
pub use ;
// Async re-exports
pub use MultiioAsyncBuilder;
pub use ;
pub use AsyncIoEngine;
pub use ;
pub use ;
/// Build a synchronous IoEngine from a PipelineConfig using the default
/// FormatRegistry.
/// Build a synchronous IoEngine from a PipelineConfig, allowing the caller to
/// further customize the MultiioBuilder before it is built. This is a natural
/// hook point for registering custom formats or tweaking options based on the
/// parsed configuration.
// Miette re-exports
pub use IoDiagnostic;
// Internal test modules (see src/tests)