Skip to main content

cell_model/
manifest.rs

1// cell-model/src/manifest.rs
2// SPDX-License-Identifier: MIT
3
4use alloc::string::String;
5use alloc::vec::Vec;
6use serde::{Deserialize, Serialize};
7use std::collections::HashMap;
8
9#[derive(Debug, Serialize, Deserialize, Clone)]
10pub struct CellManifest {
11    pub package: Option<PackageMeta>, // Support standard Cargo.toml structure
12    pub cell: Option<CellMeta>,       // Support explicit [cell] block
13
14    #[serde(default)]
15    pub neighbors: HashMap<String, NeighborConfig>,
16
17    #[serde(default)]
18    pub local: HashMap<String, String>,
19    #[serde(default)]
20    pub handlers: Vec<HandlerMeta>,
21    #[serde(default)]
22    pub macros: HashMap<String, String>,
23    pub workspace: Option<WorkspaceMeta>,
24
25    #[serde(default)]
26    pub resources: ResourceLimits,
27    #[serde(default)]
28    pub placement: PlacementStrategy,
29}
30
31#[derive(Debug, Serialize, Deserialize, Clone)]
32pub struct PackageMeta {
33    pub name: String,
34    pub version: String,
35}
36
37#[derive(Debug, Serialize, Deserialize, Clone)]
38pub struct CellMeta {
39    pub name: String,
40    pub version: String,
41}
42
43#[derive(Debug, Serialize, Deserialize, Clone)]
44#[serde(untagged)]
45pub enum NeighborConfig {
46    Path(String),
47    Detailed {
48        path: String,
49        #[serde(default)]
50        autostart: bool,
51    },
52}
53
54#[derive(Debug, Serialize, Deserialize, Clone)]
55pub struct WorkspaceMeta {
56    pub namespace: String,
57}
58
59#[derive(Debug, Serialize, Deserialize, Clone)]
60pub struct HandlerMeta {
61    pub name: String,
62}
63
64#[derive(Debug, Serialize, Deserialize, Clone, Default)]
65pub struct ResourceLimits {
66    pub cpu: Option<f32>,
67    pub mem: Option<String>,
68    pub gpu: bool,
69}
70
71#[derive(Debug, Serialize, Deserialize, Clone, Default)]
72pub struct PlacementStrategy {
73    pub zone: Option<String>,
74    pub required_instruction_set: Option<String>,
75    pub require_tee: bool,
76}