microcad_lang/model/attribute/
measure_command.rs

1// Copyright © 2025 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Measure model attribute.
5
6use crate::value::Value;
7
8/// Measure attribute.
9#[derive(Clone, Debug, Default)]
10pub enum MeasureCommand {
11    /// Measure the size of a geometry (for each dimension).
12    #[default]
13    Size,
14
15    /// Width command
16    Width,
17
18    /// Height command
19    Height,
20}
21
22impl From<MeasureCommand> for Value {
23    fn from(command: MeasureCommand) -> Self {
24        match command {
25            MeasureCommand::Size => Value::String("size".into()),
26            MeasureCommand::Width => Value::String("width".into()),
27            MeasureCommand::Height => Value::String("height".into()),
28        }
29    }
30}
31
32impl std::fmt::Display for MeasureCommand {
33    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34        match self {
35            MeasureCommand::Size => write!(f, "Size"),
36            MeasureCommand::Width => write!(f, "Width"),
37            MeasureCommand::Height => write!(f, "Height"),
38        }
39    }
40}