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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
//! Compile-time Arrow schema definition using Rust types.
//!
//! `typed-arrow` maps Rust structs directly to Arrow schemas, builders, and arrays
//! without runtime `DataType` switching. This enables zero-cost, monomorphized
//! column construction with compile-time type safety.
//!
//! # Quick Start
//!
//! ```
//! use typed_arrow::prelude::*;
//!
//! #[derive(Record)]
//! struct Person {
//! id: i64,
//! name: String,
//! score: Option<f64>,
//! }
//!
//! // Build arrays from rows
//! let rows = vec![
//! Person {
//! id: 1,
//! name: "Alice".into(),
//! score: Some(95.5),
//! },
//! Person {
//! id: 2,
//! name: "Bob".into(),
//! score: None,
//! },
//! ];
//!
//! let mut builders = <Person as BuildRows>::new_builders(rows.len());
//! builders.append_rows(rows);
//! let batch = builders.finish().into_record_batch();
//!
//! assert_eq!(batch.num_rows(), 2);
//! assert_eq!(batch.num_columns(), 3);
//! ```
//!
//! # Cargo Features
//!
//! | Feature | Default | Description |
//! |---------|---------|-------------|
//! | `derive` | ✓ | Enables [`#[derive(Record)]`](Record) and [`#[derive(Union)]`](Union) macros |
//! | `views` | ✓ | Zero-copy views for reading [`RecordBatch`](arrow_array::RecordBatch) data |
//! | `ext-hooks` | | Extensibility hooks for custom derive behavior |
//! | `arrow-55` | | Use Arrow 55.x crates |
//! | `arrow-56` | | Use Arrow 56.x crates |
//! | `arrow-57` | | Use Arrow 57.x crates |
//! | `arrow-58` | ✓ | Use Arrow 58.x crates |
//!
//! Exactly one Arrow feature must be enabled.
//!
//! # Derive Macros
//!
//! ## `#[derive(Record)]`
//!
//! Generates Arrow schema traits for structs. See [`schema::Record`] for the marker trait.
//!
//! ```
//! use typed_arrow::prelude::*;
//!
//! #[derive(Record)]
//! struct Event {
//! id: i64, // Non-null Int64
//! name: Option<String>, // Nullable Utf8
//! #[record(name = "eventType")] // Override Arrow field name
//! event_type: String,
//! }
//! ```
//!
//! **Field attributes:**
//! - `#[record(name = "...")]` — Override the Arrow field name
//! - `#[arrow(nullable)]` — Force nullability even without `Option<T>`
//! - `#[metadata(k = "key", v = "value")]` — Add field-level metadata
//! - `#[schema_metadata(k = "key", v = "value")]` — Add schema-level metadata (on struct)
//!
//! ## `#[derive(Union)]`
//!
//! Generates Arrow Union type bindings for enums. Implements
//! [`ArrowBinding`](bridge::ArrowBinding).
//!
//! ```
//! use typed_arrow::prelude::*;
//!
//! #[derive(Union)]
//! #[union(mode = "dense")] // or "sparse"
//! enum Value {
//! #[union(tag = 0)]
//! Int(i32),
//! #[union(tag = 1, field = "text")]
//! Str(String),
//! }
//! ```
//!
//! **Container attributes:**
//! - `#[union(mode = "dense"|"sparse")]` — Union mode (default: dense)
//! - `#[union(null_variant = "None")]` — Designate a null-carrier variant
//! - `#[union(tags(A = 0, B = 1))]` — Set all variant tags at once
//!
//! **Variant attributes:**
//! - `#[union(tag = N)]` — Set type ID for this variant
//! - `#[union(field = "name")]` — Override Arrow field name
//! - `#[union(null)]` — Mark as the null-carrier variant
//!
//! # Core Traits
//!
//! ## Schema Traits (in [`schema`] module)
//!
//! | Trait | Description |
//! |-------|-------------|
//! | [`Record`](schema::Record) | Marker for structs with `const LEN: usize` columns |
//! | [`ColAt<I>`](schema::ColAt) | Per-column metadata: `Native`, `ColumnArray`, `ColumnBuilder`, `NULLABLE`, `NAME`, `data_type()` |
//! | [`ForEachCol`](schema::ForEachCol) | Compile-time column iteration via [`ColumnVisitor`](schema::ColumnVisitor) |
//! | [`SchemaMeta`](schema::SchemaMeta) | Runtime schema access: `fields()`, `schema()`, `metadata()` |
//! | [`StructMeta`](schema::StructMeta) | Nested struct support: `child_fields()`, `new_struct_builder()` |
//!
//! ## Row Building Traits (in [`schema`] module)
//!
//! | Trait | Description |
//! |-------|-------------|
//! | [`BuildRows`](schema::BuildRows) | Entry point: `new_builders(capacity)` → `Builders` |
//! | [`RowBuilder<T>`](schema::RowBuilder) | `append_row()`, `append_rows()`, `append_option_row()`, `finish()` |
//! | [`IntoRecordBatch`](schema::IntoRecordBatch) | Convert finished arrays to [`RecordBatch`](arrow_array::RecordBatch) |
//! | [`AppendStruct`](schema::AppendStruct) | Append struct fields into a `StructBuilder` |
//!
//! ## Type Binding Trait (in [`bridge`] module)
//!
//! | Trait | Description |
//! |-------|-------------|
//! | [`ArrowBinding`](bridge::ArrowBinding) | Maps Rust types to Arrow: `Builder`, `Array`, `data_type()`, `append_value()`, `finish()` |
//!
//! # Supported Types
//!
//! ## Primitives
//!
//! | Rust Type | Arrow Type |
//! |-----------|------------|
//! | `i8`, `i16`, `i32`, `i64` | `Int8`, `Int16`, `Int32`, `Int64` |
//! | `u8`, `u16`, `u32`, `u64` | `UInt8`, `UInt16`, `UInt32`, `UInt64` |
//! | `f32`, `f64` | `Float32`, `Float64` |
//! | [`half::f16`] | `Float16` |
//! | `bool` | `Boolean` |
//!
//! ## Strings & Binary
//!
//! | Rust Type | Arrow Type |
//! |-----------|------------|
//! | `String` | `Utf8` |
//! | [`LargeUtf8`] | `LargeUtf8` (64-bit offsets) |
//! | `Vec<u8>` | `Binary` |
//! | [`LargeBinary`] | `LargeBinary` (64-bit offsets) |
//! | `[u8; N]` | `FixedSizeBinary(N)` |
//!
//! ## Nullability
//!
//! | Rust Type | Arrow Nullability |
//! |-----------|-------------------|
//! | `T` | Non-nullable column |
//! | `Option<T>` | Nullable column |
//! | [`Null`] | `Null` type (always null) |
//!
//! ## Temporal Types
//!
//! | Rust Type | Arrow Type |
//! |-----------|------------|
//! | [`Date32`] | `Date32` (days since epoch) |
//! | [`Date64`] | `Date64` (milliseconds since epoch) |
//! | [`Time32<U>`](Time32) | `Time32` with unit `U` ([`Second`], [`Millisecond`]) |
//! | [`Time64<U>`](Time64) | `Time64` with unit `U` ([`Microsecond`], [`Nanosecond`]) |
//! | [`Timestamp<U>`] | `Timestamp` without timezone |
//! | [`TimestampTz<U, Z>`] | `Timestamp` with timezone `Z` (e.g., [`Utc`]) |
//! | [`Duration<U>`](Duration) | `Duration` with unit `U` |
//!
//! ## Intervals
//!
//! | Rust Type | Arrow Type |
//! |-----------|------------|
//! | [`IntervalYearMonth`] | `Interval(YearMonth)` |
//! | [`IntervalDayTime`] | `Interval(DayTime)` |
//! | [`IntervalMonthDayNano`] | `Interval(MonthDayNano)` |
//!
//! ## Decimal
//!
//! | Rust Type | Arrow Type |
//! |-----------|------------|
//! | [`Decimal128<P, S>`](Decimal128) | `Decimal128(P, S)` |
//! | [`Decimal256<P, S>`](Decimal256) | `Decimal256(P, S)` |
//!
//! ## Nested Types
//!
//! | Rust Type | Arrow Type |
//! |-----------|------------|
//! | `#[derive(Record)]` struct | `Struct` |
//! | [`List<T>`] | `List` (non-null items) |
//! | [`List<Option<T>>`](List) | `List` (nullable items) |
//! | [`LargeList<T>`](LargeList) | `LargeList` (64-bit offsets) |
//! | [`FixedSizeList<T, N>`](FixedSizeList) | `FixedSizeList(N)` (non-null items) |
//! | [`FixedSizeListNullable<T, N>`](FixedSizeListNullable) | `FixedSizeList(N)` (nullable items) |
//! | [`Map<K, V>`] | `Map` (non-null values) |
//! | [`Map<K, Option<V>>`](Map) | `Map` (nullable values) |
//! | [`OrderedMap<K, V>`] | `Map` with `keys_sorted = true` |
//! | [`Dictionary<K, V>`] | `Dictionary` (K: integral, V: string/binary/primitive) |
//! | `#[derive(Union)]` enum | `Union` (Dense or Sparse) |
//!
//! # Zero-Copy Views (requires `views` feature)
//!
//! Read [`RecordBatch`](arrow_array::RecordBatch) data without allocation.
//! Use [`AsViewsIterator::iter_views`] to iterate over borrowed row views,
//! and [`.try_into()`](TryInto::try_into) to convert views to owned records.
//!
//! See the [`schema`] module for detailed documentation and examples.
//!
//! # Extensibility (requires `ext-hooks` feature)
//!
//! Customize derive behavior with hooks:
//!
//! ```ignore
//! #[derive(Record)]
//! #[record(visit(MyVisitor))] // Inject compile-time visitor
//! #[record(field_macro = my_ext::per_field)] // Call macro per field
//! #[record(record_macro = my_ext::per_record)] // Call macro per record
//! struct MyRecord {
//! #[record(ext(custom_tag))] // Tag fields with markers
//! field: i32,
//! }
//! ```
//!
//! See `examples/12_ext_hooks.rs` for usage.
compile_error!;
compile_error!;
compile_error!;
compile_error!;
pub extern crate arrow_array_55 as arrow_array;
pub extern crate arrow_array_56 as arrow_array;
pub extern crate arrow_array_57 as arrow_array;
pub extern crate arrow_array_58 as arrow_array;
pub extern crate arrow_buffer_55 as arrow_buffer;
pub extern crate arrow_buffer_56 as arrow_buffer;
pub extern crate arrow_buffer_57 as arrow_buffer;
pub extern crate arrow_buffer_58 as arrow_buffer;
pub extern crate arrow_data_55 as arrow_data;
pub extern crate arrow_data_56 as arrow_data;
pub extern crate arrow_data_57 as arrow_data;
pub extern crate arrow_data_58 as arrow_data;
pub extern crate arrow_schema_55 as arrow_schema;
pub extern crate arrow_schema_56 as arrow_schema;
pub extern crate arrow_schema_57 as arrow_schema;
pub extern crate arrow_schema_58 as arrow_schema;
/// Prelude exporting the most common traits and markers.
// Re-export the derive macro when enabled
// Re-export Arrow crates so derives can reference a stable path
// and downstream users don't need to depend on Arrow directly.
pub use ;
// Public re-exports for convenience
pub use crate;
/// Extension trait for creating typed view iterators from `RecordBatch`.