Skip to main content

ptars_core/
lib.rs

1//! # ptars-core
2//!
3//! Fast conversion from Protocol Buffers to Apache Arrow and back.
4//!
5//! This crate provides efficient conversion between Protocol Buffer messages
6//! and Apache Arrow record batches, enabling high-performance data processing
7//! pipelines that bridge the protobuf and Arrow ecosystems.
8//!
9//! Its public API exposes arrow-rs and prost-reflect types, which means users
10//! must depend on the same major version of arrow and prost-reflect as this
11//! crate. If you want to exchange Arrow data without matching those versions,
12//! use the `ptars` crate instead: it exposes only the
13//! [Arrow C Data Interface](https://arrow.apache.org/docs/format/CDataInterface.html)
14//! for zero-copy data exchange.
15//!
16//! ## Features
17//!
18//! - Convert protobuf messages to Arrow RecordBatch
19//! - Convert Arrow RecordBatch back to protobuf messages
20//! - Support for nested messages, repeated fields, and maps
21//! - Special handling for well-known types (Timestamp, Date, TimeOfDay, wrapper types)
22//!
23//! ## Example
24//!
25//! ```ignore
26//! use ptars_core::{binary_array_to_record_batch_direct, PtarsConfig};
27//! use arrow_array::BinaryArray;
28//! use prost_reflect::DescriptorPool;
29//!
30//! // Load your protobuf descriptor
31//! let pool = DescriptorPool::decode(descriptor_bytes).unwrap();
32//! let message_descriptor = pool.get_message_by_name("my.Message").unwrap();
33//!
34//! // Decode serialized protobuf messages directly to Arrow
35//! let binary_array: BinaryArray = /* your serialized messages */;
36//! let config = PtarsConfig::default();
37//! let record_batch = binary_array_to_record_batch_direct(&binary_array, &message_descriptor, &config).unwrap();
38//! ```
39
40pub mod arrow_to_proto;
41pub mod config;
42pub mod proto_to_arrow;
43
44#[cfg(test)]
45mod converter;
46
47// Re-export commonly used items
48pub use arrow_to_proto::record_batch_to_array;
49pub use config::{ConfluentWirePolicy, EnumRepr, PtarsConfig, TimeUnit};
50pub use proto_to_arrow::{
51    binary_array_to_messages, binary_array_to_record_batch_direct, messages_to_record_batch,
52    messages_to_record_batch_with_config,
53};