1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
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.
#[schema(nullable = false)]
pub(crate) description: Option<String>,
/// 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);
|