1mod document_rows;
7mod mapped_bytes;
8mod ndjson;
9mod ndjson_byte;
10mod ndjson_direct;
11mod ndjson_driver;
12mod ndjson_distinct;
13mod ndjson_frame;
14mod ndjson_hint;
15mod ndjson_parallel;
16mod ndjson_rev;
17mod ndjson_route;
18mod ndjson_row;
19mod ndjson_rows;
20mod ndjson_scan;
21mod ndjson_stream_cache;
22mod ndjson_write;
23mod source;
24mod stream_direct;
25mod stream_exec;
26mod stream_fanout;
27mod stream_numeric;
28mod stream_plan;
29mod stream_source;
30mod stream_subquery;
31mod stream_types;
32
33pub(crate) use document_rows::collect_document_rows;
34pub use ndjson::{
35 collect_ndjson, collect_ndjson_file, collect_ndjson_file_with_options, collect_ndjson_matches,
36 collect_ndjson_matches_file, collect_ndjson_matches_file_with_options,
37 collect_ndjson_matches_source, collect_ndjson_matches_source_with_options,
38 collect_ndjson_matches_with_options, collect_ndjson_source, collect_ndjson_source_with_options,
39 collect_ndjson_with_options, for_each_ndjson, for_each_ndjson_source,
40 for_each_ndjson_source_until, for_each_ndjson_source_until_with_options,
41 for_each_ndjson_source_with_options, for_each_ndjson_until, for_each_ndjson_until_with_options,
42 for_each_ndjson_with_options, ndjson_writer_path_kind, run_ndjson, run_ndjson_file,
43 run_ndjson_file_limit, run_ndjson_file_limit_with_options, run_ndjson_file_with_options,
44 run_ndjson_file_limit_with_report, run_ndjson_file_limit_with_report_and_options,
45 run_ndjson_file_with_report, run_ndjson_file_with_report_and_options, run_ndjson_limit,
46 run_ndjson_limit_with_options, run_ndjson_limit_with_report,
47 run_ndjson_limit_with_report_and_options, run_ndjson_matches, run_ndjson_matches_file,
48 run_ndjson_matches_file_with_options, run_ndjson_matches_file_with_report,
49 run_ndjson_matches_file_with_report_and_options, run_ndjson_matches_source,
50 run_ndjson_matches_source_with_options, run_ndjson_matches_source_with_report,
51 run_ndjson_matches_source_with_report_and_options, run_ndjson_matches_with_options,
52 run_ndjson_source,
53 run_ndjson_matches_with_report, run_ndjson_matches_with_report_and_options,
54 run_ndjson_source_limit, run_ndjson_source_limit_with_options, run_ndjson_source_with_options,
55 run_ndjson_source_limit_with_report, run_ndjson_source_limit_with_report_and_options,
56 run_ndjson_source_with_report, run_ndjson_source_with_report_and_options,
57 run_ndjson_with_options, run_ndjson_with_report, run_ndjson_with_report_and_options,
58 NdjsonControl, NdjsonNullOutput, NdjsonOptions, NdjsonParallelism, NdjsonWriterPathKind,
59};
60pub use ndjson_driver::NdjsonPerRowDriver;
61pub use ndjson_distinct::DistinctFrontFilterKind;
62pub use ndjson_frame::{NdjsonRowFrame, NullPayload};
63pub use ndjson_rev::{
64 collect_ndjson_rev, collect_ndjson_rev_matches, collect_ndjson_rev_matches_with_options,
65 collect_ndjson_rev_with_options, for_each_ndjson_rev, for_each_ndjson_rev_with_options,
66 run_ndjson_rev, run_ndjson_rev_distinct_by, run_ndjson_rev_distinct_by_with_options,
67 run_ndjson_rev_distinct_by_with_report, run_ndjson_rev_distinct_by_with_report_and_options,
68 run_ndjson_rev_distinct_by_with_stats, run_ndjson_rev_distinct_by_with_stats_and_options,
69 run_ndjson_rev_limit, run_ndjson_rev_limit_with_options, run_ndjson_rev_matches,
70 run_ndjson_rev_matches_with_options, run_ndjson_rev_matches_with_report,
71 run_ndjson_rev_matches_with_report_and_options, run_ndjson_rev_with_options,
72 NdjsonRevDistinctStats, NdjsonReverseFileDriver,
73};
74pub use ndjson_route::{
75 ndjson_explain, NdjsonExecutionReport, NdjsonExecutionStats, NdjsonFallbackReason,
76 NdjsonRouteExplain, NdjsonRouteKind, NdjsonSourceCaps, NdjsonSourceMode,
77};
78pub use ndjson_rows::{ndjson_rows_plan_kind, NdjsonRowsPlanKind};
79pub use source::NdjsonSource;
80use std::fmt;
81
82#[derive(Debug)]
84pub enum RowError {
85 Io(std::io::Error),
86 InvalidJson {
87 line_no: u64,
88 source: serde_json::Error,
89 },
90 InvalidJsonMessage {
91 line_no: u64,
92 message: String,
93 },
94 EmptyPayload {
95 line_no: u64,
96 },
97 NullPayload {
98 line_no: u64,
99 },
100 LineTooLarge {
101 line_no: u64,
102 len: usize,
103 max: usize,
104 },
105}
106
107impl RowError {
108 pub fn invalid_json(line_no: u64, source: serde_json::Error) -> Self {
109 Self::InvalidJson { line_no, source }
110 }
111}
112
113impl fmt::Display for RowError {
114 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
115 match self {
116 Self::Io(err) => write!(f, "{}", err),
117 Self::InvalidJson { line_no, source } => {
118 write!(f, "invalid JSON on NDJSON line {line_no}: {source}")
119 }
120 Self::InvalidJsonMessage { line_no, message } => {
121 write!(f, "invalid JSON on NDJSON line {line_no}: {message}")
122 }
123 Self::EmptyPayload { line_no } => {
124 write!(f, "NDJSON line {line_no} has an empty framed payload")
125 }
126 Self::NullPayload { line_no } => {
127 write!(f, "NDJSON line {line_no} has a null framed payload")
128 }
129 Self::LineTooLarge { line_no, len, max } => write!(
130 f,
131 "NDJSON line {line_no} is too large: {len} bytes exceeds {max} byte limit"
132 ),
133 }
134 }
135}
136
137impl std::error::Error for RowError {
138 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
139 match self {
140 Self::Io(err) => Some(err),
141 Self::InvalidJson { source, .. } => Some(source),
142 Self::InvalidJsonMessage { .. } => None,
143 Self::EmptyPayload { .. } => None,
144 Self::NullPayload { .. } => None,
145 Self::LineTooLarge { .. } => None,
146 }
147 }
148}
149
150impl From<std::io::Error> for RowError {
151 fn from(err: std::io::Error) -> Self {
152 Self::Io(err)
153 }
154}