lenso_app_plan/
execution.rs1use std::fmt;
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
9pub struct ExecutionLaneId(String);
10
11impl ExecutionLaneId {
12 pub fn new(value: impl Into<String>) -> Self {
14 Self(value.into())
15 }
16
17 pub fn main() -> Self {
19 Self::new("main")
20 }
21
22 pub fn as_str(&self) -> &str {
24 &self.0
25 }
26}
27
28impl Default for ExecutionLaneId {
29 fn default() -> Self {
30 Self::main()
31 }
32}
33
34impl fmt::Display for ExecutionLaneId {
35 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
36 formatter.write_str(self.as_str())
37 }
38}
39
40#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
42pub struct ExecutionLanePlan {
43 id: ExecutionLaneId,
44}
45
46impl ExecutionLanePlan {
47 pub fn new(id: impl Into<String>) -> Self {
49 Self {
50 id: ExecutionLaneId::new(id),
51 }
52 }
53
54 pub const fn id(&self) -> &ExecutionLaneId {
56 &self.id
57 }
58}
59
60#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
66pub struct ExecutionClassId(String);
67
68impl ExecutionClassId {
69 pub fn new(value: impl Into<String>) -> Self {
71 Self(value.into())
72 }
73
74 pub fn native_rust() -> Self {
76 Self::new("lenso.native-rust@1")
77 }
78
79 pub fn bun_child_process() -> Self {
81 Self::new("lenso.bun-process@1")
82 }
83
84 pub fn as_str(&self) -> &str {
86 &self.0
87 }
88}
89
90impl fmt::Display for ExecutionClassId {
91 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
92 formatter.write_str(self.as_str())
93 }
94}