use serde::{Deserialize, Serialize}; use utoipa::ToSchema; use crate::storage::sql::{mk_id, unit_property::UnitPropertyId}; #[derive(ToSchema, Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Serialize, Deserialize)] pub(crate) struct Unit { /// Unique id for this unit. pub(crate) id: UnitId, /// The singular version of this unit's name. /// E.g.: /// Kilogram /// Gram pub(crate) full_name_singular: String, /// The plural version of this unit's name. Is used by a value of two and more. /// (We do not support Slovenian dual numerus versions) /// E.g.: /// Kilogram -> Kilograms /// gram -> meters pub(crate) full_name_plural: String, /// Short name or abbreviation of this unit. /// E.g.: /// kg for Kilogram /// g for gram /// m for meter pub(crate) short_name: String, /// Description of this unit. pub(crate) description: Option, /// Which property is described by this unit. /// E.g.: /// kg -> Mass /// L -> Volume /// m/s -> Speed /// and so forth pub(crate) unit_property: UnitPropertyId, } #[derive(ToSchema, Debug, Clone, Copy, Serialize, Deserialize)] pub(crate) struct UnitAmount { #[schema(minimum = 0)] pub(crate) value: u32, pub(crate) unit: UnitId, } mk_id!(UnitId and UnitIdStub);