Skip to main content

microcad_lang/model/
creator.rs

1// Copyright © 2025-2026 The µcad authors <info@microcad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Creator of work pieces.
5
6use crate::{
7    symbol::{Info, Symbol, SymbolInfo},
8    value::Tuple,
9};
10
11/// A creator is the origin  
12#[derive(Debug, Clone)]
13pub struct Creator {
14    /// Symbol.
15    pub symbol: Symbol,
16    /// Workpiece arguments.
17    pub arguments: Tuple,
18}
19
20impl Creator {
21    /// New creator.
22    pub fn new(symbol: Symbol, arguments: Tuple) -> Self {
23        Self { symbol, arguments }
24    }
25}
26
27impl Info for Creator {
28    fn info(&self) -> SymbolInfo {
29        self.symbol.info()
30    }
31}
32
33impl std::fmt::Display for Creator {
34    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35        write!(
36            f,
37            "{symbol}{arguments}",
38            symbol = self.symbol.full_name(),
39            arguments = self.arguments
40        )
41    }
42}
43
44impl std::hash::Hash for Creator {
45    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
46        self.symbol.full_name().hash(state);
47        self.arguments.hash(state);
48    }
49}