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-types
This crate provides the core types and traits for converting Rust types to and from Apache Arrow arrays, forming the foundation of the polars-structpath ecosystem. It enables seamless bidirectional conversion between Rust data structures and Polars-compatible Arrow arrays.
Purpose
polars-structpath-types is a foundational library that provides:
- Arrow Buffer Traits: Core traits (
ArrowBuffer,IntoArrow,FromArrow) for converting Rust types to Arrow arrays - Buffer Implementations: Ready-to-use buffer implementations for:
- Primitive types:
i32,i64,u8,u32,u64,f32,f64,bool - Strings:
String - Collections:
Vec<T>andOption<T>with full nesting support - Custom types: Structs and enums via macros
- Primitive types:
- Conversion Macros: Procedural macros for generating Arrow buffer code:
impl_struct_buffer!: Generates buffer implementations for structsimpl_enum_buffer!: Generates buffer implementations for enums
- Type Safety: Compile-time type checking ensures correct Arrow array generation
Core Traits
ArrowBuffer
The main trait for types that can accumulate values and convert them to Arrow arrays:
IntoArrow
Marks types that can be converted to Arrow arrays. Provides a convenience method new_buffer():
FromArrow
Enables conversion from Arrow arrays back to Rust types:
Usage Examples
Using Built-in Types
All primitive types, strings, and collections implement IntoArrow and FromArrow:
use ;
// Create a buffer for i32 values
let mut buffer = i32new_buffer;
buffer.push;
buffer.push;
buffer.push_null;
// Convert to Arrow array
let array = buffer.to_arrow.unwrap;
// Convert back from Arrow array
let values: = i32from_arrow;
Custom Structs
Use the impl_struct_buffer! macro to generate buffer code for your structs:
use ;
impl_struct_buffer!;
// Now Person implements IntoArrow and FromArrow
let mut buffer = new_buffer;
buffer.push;
let array = buffer.to_arrow.unwrap;
Custom Enums
Use the impl_enum_buffer! macro for enums:
use ;
impl_enum_buffer!;
// Status now implements IntoArrow and FromArrow
let mut buffer = new_buffer;
buffer.push;
buffer.push;
let array = buffer.to_arrow.unwrap;
Nested Types
The crate fully supports nested Option and Vec types:
use ;
// Option<String>
let mut buffer = Option::new_buffer;
buffer.push;
buffer.push;
// Vec<i32>
let mut buffer = Vec::new_buffer;
buffer.push;
buffer.push;
// Option<Vec<String>>
let mut buffer = Option::new_buffer;
buffer.push;
buffer.push;
Integration with Polars
The Arrow arrays produced by this crate are fully compatible with Polars DataFrames:
use *;
use ;
let mut buffer = Stringnew_buffer;
buffer.push;
buffer.push;
buffer.push;
let array = buffer.to_arrow.unwrap;
let series = from_arrow.unwrap;
let df = new.unwrap;
This crate is used by:
polars-structpath: The main user-facing library that re-exports these typespolars-structpath-derive: The derive macro implementation that generates code using these typespolars-protobuf: Protocol Buffers integration that leverages these types
See Also
- Main README - Overview of the entire
polarspathecosystem - polars-structpath - User-facing API documentation
- polars-structpath-derive - Derive macro implementation
- polars-protobuf - Protocol Buffers integration