#[derive(EnumPath)]
{
// Attributes available to this derive:
#[type_hint]
#[enum_path]
}
Expand description
Derive macro for generating Arrow buffer implementations for enums.
This macro automatically generates code that calls impl_enum_buffer! from
polars-structpath, which creates:
- A buffer struct (e.g.,
StatusBuffer) implementingArrowBuffer - Helper methods for index conversion (
from_arrow_idx,rust_idx_to_arrow_idx) IntoArrowimplementation for the enumFromArrowimplementation for the enum
§Requirements
- The enum must be a unit enum (no fields in variants)
- All variants must have explicit discriminant values
§Attributes
#[type_hint(...)]: Currently accepted but not used. Reserved for future use.#[enum_path(...)]: Currently accepted but not used. Reserved for future use.
§Example
ⓘ
use polars_structpath::EnumPath;
use polars_structpath::{IntoArrow, ArrowBuffer};
#[derive(EnumPath)]
enum Status {
Active = 1,
Inactive = 2,
}
// Now Status implements IntoArrow and FromArrow
let mut buffer = Status::new_buffer(2);
buffer.push(Status::Active);
buffer.push(Status::Inactive);
let array = buffer.to_arrow().unwrap();