pub struct DimensionRegistry { /* private fields */ }Expand description
Dimension registry: maps dimension names to Dimension values and tracks
base dimension metadata (ID assignment, names, default unit symbols).
Implementations§
Source§impl DimensionRegistry
impl DimensionRegistry
Sourcepub fn get_dimension(&self, name: &str) -> Option<&Dimension>
pub fn get_dimension(&self, name: &str) -> Option<&Dimension>
Look up a dimension by name.
Sourcepub fn all_dimensions(&self) -> impl Iterator<Item = (&DimName, &Dimension)>
pub fn all_dimensions(&self) -> impl Iterator<Item = (&DimName, &Dimension)>
Iterate over all named dimensions.
Sourcepub const fn base_dim_names(&self) -> &BTreeMap<BaseDimId, String>
pub const fn base_dim_names(&self) -> &BTreeMap<BaseDimId, String>
Get the base dimension names map (for display purposes).
Sourcepub const fn base_dim_symbols(&self) -> &BTreeMap<BaseDimId, String>
pub const fn base_dim_symbols(&self) -> &BTreeMap<BaseDimId, String>
Get the base dimension symbols map for runtime display.
Sourcepub fn format_dimension(&self, dim: &Dimension) -> String
pub fn format_dimension(&self, dim: &Dimension) -> String
Format a dimension as a human-readable string using registered base dimension names.
Returns "Dimensionless" for dimensionless, or names like "Length / Time".
When a compound dimension matches a named dimension alias (e.g. Energy
for Length^2 * Mass / Time^2), the alias is preferred so diagnostics
speak the user’s vocabulary.
Sourcepub fn resolve_dim_expr(
&self,
expr: &DimExpr,
) -> Result<Option<Dimension>, RationalError>
pub fn resolve_dim_expr( &self, expr: &DimExpr, ) -> Result<Option<Dimension>, RationalError>
Resolve a DimExpr AST node to a concrete Dimension.
Returns Ok(None) if any dimension name is unknown, and Err if
dimension exponent arithmetic overflows i32.
Sourcepub fn resolve_type_expr(
&self,
type_expr: &TypeExpr,
) -> Result<Option<Dimension>, RationalError>
pub fn resolve_type_expr( &self, type_expr: &TypeExpr, ) -> Result<Option<Dimension>, RationalError>
Resolve a TypeExpr to a concrete Dimension.
Returns Ok(None) if the type references unknown dimensions, and
Err if dimension exponent arithmetic overflows i32.
Trait Implementations§
Source§impl Clone for DimensionRegistry
impl Clone for DimensionRegistry
Source§fn clone(&self) -> DimensionRegistry
fn clone(&self) -> DimensionRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more