Skip to main content

Crate octofhir_ucum_core

Crate octofhir_ucum_core 

Source
Expand description

UCUM Core Library – Rust 2024 Edition

This crate provides parsing, validation and conversion utilities for the Unified Code for Units of Measure (UCUM). It aims to be no_std-optional and suitable for both embedded and server environments.

Re-exports§

pub use crate::performance::CacheStats;
pub use crate::performance::EvaluationCache;
pub use crate::performance::find_unit_optimized;
pub use crate::performance::find_prefix_optimized;
pub use crate::performance::get_cache_stats;
pub use crate::performance::clear_global_cache;
pub use crate::performance::get_cache_sizes;
pub use crate::performance::with_global_cache;
pub use crate::performance::find_prefixes_with_trie;
pub use crate::performance::find_longest_prefix_with_trie;
pub use crate::special_units::ArbitraryHandler;
pub use crate::special_units::ConversionContext;
pub use crate::special_units::LogarithmicHandler;
pub use crate::special_units::SpecialUnitHandler;
pub use crate::special_units::SpecialUnitRegistry;
pub use crate::special_units::TemperatureHandler;
pub use crate::suggestions::SuggestionEngine;

Modules§

performance
Performance optimization module for Performance and Scalability
precision
Precision arithmetic support for UCUM calculations.
special_units
Special unit handlers for extensible UCUM special unit processing.
suggestions
Suggestion engine for error corrections and unit alternatives (Phase 5).

Structs§

AdvancedConversionContext
Advanced conversion context for enhanced conversion operations.
AdvancedConversionResult
Result of an advanced conversion operation with metadata.
BaseUnit
Base unit record (e.g. metre, second, kelvin).
CanonicalUnit
Canonical unit representation
DerivedUnit
Derived or custom unit that resolves to a base vector plus factor/offset.
Dimension
Dimensional vector (M, L, T, I, Θ, N, J) per UCUM spec.
EvalResult
Result returned by evaluate() – canonical factor, dimension vector, offset.
MeasurementContext
Measurement context providing domain-specific preferences and requirements.
PrecisionRequirements
Precision requirements for different domains.
Prefix
SI prefix such as k (kilo) or m (milli).
Quantity
Numerical quantity paired with a unit expression.
Span
Source location information for parser errors
UcumError
Enhanced UCUM error with detailed context and suggestions
UcumModel
UCUM model information and metadata.
UnitAnalysis
Detailed analysis result for a UCUM expression.
UnitArithmeticResult
Result of unit arithmetic operations
UnitFactor
A base expression accompanied by an integer exponent (default 1).
UnitRecord
UnitResult
Result of mathematical operations with units

Enums§

ConceptKind
Concept kinds for filtering search results.
DecimalPrecision
Decimal precision configuration.
Domain
Domain-specific context for measurements.
ErrorKind
Specific error kinds with detailed context
RoundingMode
Rounding mode for conversions.
TemperatureScale
Temperature scale preference.
UnitExpr
A fully parsed UCUM expression.

Functions§

analyse
Analyse a UCUM expression and return detailed information about it.
canonicalize_expression
Convert a unit expression to its canonical (base units) form.
convert_with_context
Convert with advanced context and precision control.
divide_by
Divide two quantities with units.
eval
Evaluate a parsed UnitExpr into canonical factor, dimension and offset. Uses enhanced caching to avoid re-computing the same expressions.
evaluate
Evaluate a parsed UnitExpr into canonical factor, dimension and offset. Uses enhanced caching to avoid re-computing the same expressions.
find_prefix
Lookup a prefix by symbol.
find_unit
Lookup a unit by code using the generated registry.
generate_display_name
Generate a human-readable display name for a UCUM expression.
get_all_units
Get all units from the registry.
get_canonical_units
Get the canonical units for a given UCUM expression.
get_common_display
Get a human-readable display name for a unit code.
get_defined_forms
Get all defined forms of a unit code.
get_model
Get the UCUM model information.
get_properties
Get all available properties in the UCUM model.
is_comparable
Check if two units are commensurable (can be converted between each other).
multiply
Multiply two quantities with units.
optimize_expression
Optimize a unit expression for better readability and canonical form.
parse_expression
Parse a UCUM expression string into a UnitExpr AST.
search_units
Search for units by name, code, or display name.
search_units_by_property
Search for units by property (e.g., “length”, “mass”, “time”).
search_units_filtered
Search for units with concept kind filtering.
search_units_fuzzy
Search for units using fuzzy matching.
search_units_regex
Search for units using regular expressions.
simplify_expression
Simplify a unit expression by combining like terms and reducing complexity.
unit_divide
Divide one unit expression by another.
unit_multiply
Multiply two unit expressions together.
validate
Validate a UCUM expression string.
validate_canonical_units
Validate that canonical units match the expected form.
validate_in_property
Validate that a unit expression is appropriate for a given property.
validate_ucum
Validate the UCUM implementation for self-consistency.