Skip to main content

rocie_client/models/
unit.rs

1// rocie - An enterprise grocery management system
2//
3// Copyright (C) 2026 Benedikt Peetz <benedikt.peetz@b-peetz.de>
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6// This file is part of Rocie.
7//
8// You should have received a copy of the License along with this program.
9// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
10
11/*
12 * rocie-server
13 *
14 * An enterprise grocery management system - server
15 *
16 * The version of the OpenAPI document: 0.1.0
17 * Contact: benedikt.peetz@b-peetz.de
18 * Generated by: https://openapi-generator.tech
19 */
20
21use crate::models;
22use serde::{Deserialize, Serialize};
23
24#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
25pub struct Unit {
26    /// Description of this unit.
27    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
28    pub description: Option<String>,
29    /// 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
30    #[serde(rename = "full_name_plural")]
31    pub full_name_plural: String,
32    /// The singular version of this unit's name. E.g.:     Kilogram     Gram
33    #[serde(rename = "full_name_singular")]
34    pub full_name_singular: String,
35    /// Unique id for this unit.
36    #[serde(rename = "id")]
37    pub id: models::UnitId,
38    /// Short name or abbreviation of this unit. E.g.:     kg for Kilogram     g for gram     m for meter
39    #[serde(rename = "short_name")]
40    pub short_name: String,
41    /// Which property is described by this unit. E.g.:     kg -> Mass     L -> Volume     m/s -> Speed     and so forth
42    #[serde(rename = "unit_property")]
43    pub unit_property: models::UnitPropertyId,
44}
45
46impl Unit {
47    pub fn new(
48        full_name_plural: String,
49        full_name_singular: String,
50        id: models::UnitId,
51        short_name: String,
52        unit_property: models::UnitPropertyId,
53    ) -> Unit {
54        Unit {
55            description: None,
56            full_name_plural,
57            full_name_singular,
58            id,
59            short_name,
60            unit_property,
61        }
62    }
63}