/* * unit_converter length_units.rs * - generic stuff for all units * * Copyright (C) 2025 Real Microsoft, LLC * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ use crate::length_units::LengthUnit; use astro_float::BigFloat; pub trait ConvertTo { fn convert_to(self, value: BigFloat, into: B) -> BigFloat; } pub trait BestUnit { fn best_unit(self, value: BigFloat) -> Self; } pub trait UnitName { fn unit_name(self, value: BigFloat) -> String; } pub trait FromUnitName { fn parse(value: String) -> Option<(T, String)>; } pub enum Unit { Length(LengthUnit), } #[derive(Ord, PartialOrd, Eq, PartialEq, Copy, Clone, Debug)] pub enum MetricPrefix { Pico, Nano, Micro, Milli, Centi, Deci, None, Deca, Hecto, Kilo, Mega, Giga, Tera, }