ih_muse_proto/
element.rs

1// crates/ih-muse-proto/src/element.rs
2
3use std::collections::HashMap;
4
5use serde::{Deserialize, Serialize};
6use uuid::Uuid;
7
8use crate::types::*;
9use crate::utils::deterministic_u64_from_str;
10
11pub fn generate_local_element_id() -> Uuid {
12    Uuid::new_v4()
13}
14
15// src/lib.rs
16#[derive(Debug, Serialize, Deserialize, Clone)]
17pub struct ElementRegistration {
18    kind_id: ElementKindId,
19    pub name: String,
20    pub metadata: HashMap<String, String>,
21    pub parent_id: Option<ElementId>,
22}
23
24impl ElementRegistration {
25    pub fn new(
26        kind_code: &str,
27        name: String,
28        metadata: HashMap<String, String>,
29        parent_id: Option<ElementId>,
30    ) -> Self {
31        Self {
32            kind_id: deterministic_u64_from_str(kind_code),
33            name,
34            metadata,
35            parent_id,
36        }
37    }
38}
39
40#[derive(Deserialize, Serialize, Debug)]
41pub struct NewElementsResponse {
42    // Using String for errors instead of Error
43    pub results: Vec<Result<u64, String>>,
44}