paft-utils
Shared utilities used by paft crates: canonical string tokens for open enums and optional Polars DataFrame traits.
- Canonical string utilities:
Canonical,CanonicalError,MAX_CANONICAL_TOKEN_LEN,StringCode,canonicalize,has_canonical_token_boundaries - DataFrame traits behind
dataframe:Columnar,Decimal128Encode,ToDataFrame,ToDataFrameVec
Install
Prefer the facade crate for most applications:
[]
= "0.9.0"
Direct dependency for enum/token helpers:
[]
= { = "0.9.0", = false }
With DataFrame helpers:
[]
= { = "0.9.0", = false, = ["dataframe"] }
With DataFrame helpers and the bigdecimal decimal backend:
[]
= { = "0.9.0", = false, = ["dataframe", "bigdecimal"] }
Features
Default features are empty.
dataframe: enable the shareddf-derive-core/Polars trait runtime andDecimal128Encodefor the activepaft-decimalbackendbigdecimal: when combined withdataframe, switch decimal128 encoding fromrust_decimal::Decimaltobigdecimal::BigDecimal
Quickstart
use ;
assert_eq!;
let c = try_new.unwrap;
assert_eq!;
Canonical codes
canonicalize normalizes provider strings into [A-Z0-9]+(?:_[A-Z0-9]+)*
tokens. It can return an empty string when the input has no ASCII
alphanumerics; use Canonical::try_new for values that will be stored or
serialized as an open-enum Other code.
use ;
assert_eq!;
assert_eq!;
let token = try_new.unwrap;
assert_eq!;
assert!;
Enum parsers use has_canonical_token_boundaries before resolving aliases so
inputs such as "$USD" or "CLOSED!" are not silently mapped to modeled enum
variants.
DataFrame traits
Enable dataframe when a downstream crate or derive macro needs the shared
trait identity. The traits are available from paft_utils::dataframe and are
also re-exported at the crate root when the feature is enabled.
Decimal128Encode produces the i128 mantissa expected by Polars decimal
columns, using half-even rounding on scale-down and returning None when the
value cannot fit Polars decimal precision.
Links
- API docs: https://docs.rs/paft-utils
- Workspace overview: https://github.com/paft-rs/paft/blob/main/README.md
- License: LICENSE