paft_utils/lib.rs
1#![forbid(unsafe_code)]
2#![warn(missing_docs)]
3
4//! Shared utility helpers used across the paft workspace.
5//!
6//! This crate provides:
7//! - Canonical string utilities (`Canonical`, `canonicalize`) for enum `Other` variants
8//! with a bounded stored-token length (`MAX_CANONICAL_TOKEN_LEN`)
9//! - Optional dataframe helpers for converting domain structs to `polars` frames
10//!
11//! # Quickstart
12//! ```rust
13//! use paft_utils::{canonicalize, Canonical};
14//!
15//! // Normalize provider strings into canonical tokens
16//! assert_eq!(canonicalize("Euronext Paris"), "EURONEXT_PARIS");
17//!
18//! // Validate non-empty canonical tokens via the `Canonical` wrapper
19//! let c = Canonical::try_new("nasdaq").unwrap();
20//! assert_eq!(c.as_str(), "NASDAQ");
21//! ```
22//!
23//! # Feature flags
24//! - `dataframe`: enable lightweight dataframe traits for `polars`
25
26#[cfg(feature = "dataframe")]
27pub mod dataframe;
28pub mod string_canonical;
29
30#[cfg(feature = "dataframe")]
31pub use dataframe::{Columnar, Decimal128Encode, ToDataFrame, ToDataFrameVec};
32pub use string_canonical::{
33 Canonical, CanonicalError, MAX_CANONICAL_TOKEN_LEN, StringCode, canonicalize,
34 has_canonical_token_boundaries,
35};