Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
polars-structpath
The main user-facing library for converting Rust structures to and from Apache Arrow arrays, with seamless integration to Polars DataFrames. This crate provides a unified API that re-exports all necessary types, traits, and derive macros from the underlying implementation crates.
Purpose
polars-structpath is the primary entry point for the polars-structpath ecosystem. It provides:
- Unified API: A single crate that re-exports all necessary types, traits, and derive macros
- Arrow Buffer Conversion: Bidirectional conversion between Rust types and Arrow arrays via
IntoArrowandFromArrowtraits - Derive Macros: Procedural macros (
StructPath,EnumPath) that automatically generate Arrow buffer implementations - Polars Integration: Native support for Polars DataFrames using Arrow arrays
This crate contains the core types and traits directly, and optionally re-exports derive macros:
- Core types and traits:
ArrowBuffer,IntoArrow,FromArrow polars-structpath-derive: Derive macro implementations (optional, enabled viaderivefeature)
Quick Start
Add to your Cargo.toml:
[]
= { = "*", = ["derive"] }
Converting to Arrow Arrays
The derive macros automatically generate IntoArrow implementations, enabling conversion to Arrow arrays:
use ;
use *;
Converting from Arrow Arrays
The derive macros also generate FromArrow implementations for bidirectional conversion:
use ;
Handling Nullable Arrays
Use from_arrow_opt() when arrays may contain null values:
use ;
Enums
Enums with explicit discriminants can also derive EnumPath:
use ;
Core Traits
IntoArrow
Types implementing IntoArrow can create Arrow buffers for accumulating values:
use ;
let mut buffer = Stringnew_buffer;
buffer.push;
buffer.push;
let array = buffer.to_arrow.unwrap;
FromArrow
Types implementing FromArrow can be converted back from Arrow arrays:
use ;
let mut buffer = i32new_buffer;
buffer.push;
buffer.push;
buffer.push;
let array = buffer.to_arrow.unwrap;
let values: = i32from_arrow;
ArrowBuffer
The ArrowBuffer trait is used internally to accumulate values and convert them to Arrow arrays. Types implementing IntoArrow have an associated Buffer type that implements ArrowBuffer.
Features
derive(default): Enables theStructPathandEnumPathderive macrosstd(default): Standard library support
Supported Types
The derive macros support all types that implement IntoArrow and FromArrow:
- Primitive types:
i32,i64,u8,u32,u64,f32,f64,bool - Strings:
String - Collections:
Vec<T>,Option<T> - Nested combinations:
Option<Vec<T>>,Vec<Option<T>>, etc. - Custom types: Any struct or enum that also derives
StructPathorEnumPath
What the Derive Macros Generate
When you apply #[derive(StructPath)] or #[derive(EnumPath)], the macros automatically generate:
- A buffer struct (e.g.,
UserBuffer) implementingArrowBuffer IntoArrowimplementation for converting Rust types to Arrow arraysFromArrowimplementation for converting Arrow arrays back to Rust types
This enables bidirectional conversion between Rust types and Arrow arrays, making it easy to:
- Serialize Rust data structures to Arrow format for Polars DataFrames
- Deserialize Arrow arrays back to Rust types after processing
Integration with Polars
The Arrow arrays produced by this crate are fully compatible with Polars DataFrames:
use *;
use ;
let mut buffer = new_buffer;
buffer.push;
buffer.push;
buffer.push;
let array = buffer.to_arrow.unwrap;
let series = from_arrow.unwrap;
let df = new.unwrap;
See Also
- Main README - Overview of the entire polars-structpath ecosystem
- polars-structpath-derive - Derive macro implementation details
- polars-protobuf - Protocol Buffers integration