Skip to main content
← Back to kicad-monkey Rust Docs kicad-monkey Rust Crate API Reference

kicad_monkey_contracts/generated/
build_request.rs

1/// Error types.
2pub mod error {
3    /// Error from a `TryFrom` or `FromStr` implementation.
4    pub struct ConversionError(::std::borrow::Cow<'static, str>);
5    impl ::std::error::Error for ConversionError {}
6    impl ::std::fmt::Display for ConversionError {
7        fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
8            ::std::fmt::Display::fmt(&self.0, f)
9        }
10    }
11    impl ::std::fmt::Debug for ConversionError {
12        fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
13            ::std::fmt::Debug::fmt(&self.0, f)
14        }
15    }
16    impl From<&'static str> for ConversionError {
17        fn from(value: &'static str) -> Self {
18            Self(value.into())
19        }
20    }
21    impl From<String> for ConversionError {
22        fn from(value: String) -> Self {
23            Self(value.into())
24        }
25    }
26}
27///Portable generic S-expression tree node used only by explicit build operations.
28///
29/// <details><summary>JSON schema</summary>
30///
31/// ```json
32///{
33///  "description": "Portable generic S-expression tree node used only by explicit build operations.",
34///  "type": "object",
35///  "required": [
36///    "kind"
37///  ],
38///  "properties": {
39///    "children": {
40///      "type": "array",
41///      "items": {
42///        "$ref": "#/$defs/Node"
43///      }
44///    },
45///    "float": {
46///      "type": "number"
47///    },
48///    "integer": {
49///      "type": "string"
50///    },
51///    "kind": {
52///      "$ref": "#/$defs/NodeKind"
53///    },
54///    "text": {
55///      "type": "string"
56///    }
57///  },
58///  "additionalProperties": false
59///}
60/// ```
61/// </details>
62#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
63#[serde(deny_unknown_fields)]
64pub struct Node {
65    #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
66    pub children: ::std::vec::Vec<Node>,
67    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
68    pub float: ::std::option::Option<f64>,
69    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
70    pub integer: ::std::option::Option<::std::string::String>,
71    pub kind: NodeKind,
72    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
73    pub text: ::std::option::Option<::std::string::String>,
74}
75///`NodeKind`
76///
77/// <details><summary>JSON schema</summary>
78///
79/// ```json
80///{
81///  "type": "string",
82///  "enum": [
83///    "list",
84///    "atom",
85///    "quoted",
86///    "integer",
87///    "float"
88///  ]
89///}
90/// ```
91/// </details>
92#[derive(
93    ::serde::Deserialize,
94    ::serde::Serialize,
95    Clone,
96    Copy,
97    Debug,
98    Eq,
99    Hash,
100    Ord,
101    PartialEq,
102    PartialOrd,
103)]
104pub enum NodeKind {
105    #[serde(rename = "list")]
106    List,
107    #[serde(rename = "atom")]
108    Atom,
109    #[serde(rename = "quoted")]
110    Quoted,
111    #[serde(rename = "integer")]
112    Integer,
113    #[serde(rename = "float")]
114    Float,
115}
116impl ::std::fmt::Display for NodeKind {
117    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
118        match *self {
119            Self::List => f.write_str("list"),
120            Self::Atom => f.write_str("atom"),
121            Self::Quoted => f.write_str("quoted"),
122            Self::Integer => f.write_str("integer"),
123            Self::Float => f.write_str("float"),
124        }
125    }
126}
127impl ::std::str::FromStr for NodeKind {
128    type Err = self::error::ConversionError;
129    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
130        match value {
131            "list" => Ok(Self::List),
132            "atom" => Ok(Self::Atom),
133            "quoted" => Ok(Self::Quoted),
134            "integer" => Ok(Self::Integer),
135            "float" => Ok(Self::Float),
136            _ => Err("invalid value".into()),
137        }
138    }
139}
140impl ::std::convert::TryFrom<&str> for NodeKind {
141    type Error = self::error::ConversionError;
142    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
143        value.parse()
144    }
145}
146impl ::std::convert::TryFrom<&::std::string::String> for NodeKind {
147    type Error = self::error::ConversionError;
148    fn try_from(
149        value: &::std::string::String,
150    ) -> ::std::result::Result<Self, self::error::ConversionError> {
151        value.parse()
152    }
153}
154impl ::std::convert::TryFrom<::std::string::String> for NodeKind {
155    type Error = self::error::ConversionError;
156    fn try_from(
157        value: ::std::string::String,
158    ) -> ::std::result::Result<Self, self::error::ConversionError> {
159        value.parse()
160    }
161}
162///Deterministic generic-tree build request.
163///
164/// <details><summary>JSON schema</summary>
165///
166/// ```json
167///{
168///  "$id": "urn:wavenumber:schema:kicad_monkey.sexpr_build.request:a0",
169///  "title": "S-expression build request a0",
170///  "description": "Deterministic generic-tree build request.",
171///  "type": "object",
172///  "required": [
173///    "root",
174///    "type",
175///    "version"
176///  ],
177///  "properties": {
178///    "root": {
179///      "$ref": "#/$defs/Node"
180///    },
181///    "type": {
182///      "type": "string",
183///      "const": "kicad_monkey.sexpr_build.request"
184///    },
185///    "version": {
186///      "type": "string",
187///      "const": "a0"
188///    }
189///  },
190///  "additionalProperties": false
191///}
192/// ```
193/// </details>
194#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
195#[serde(deny_unknown_fields)]
196pub struct SExpressionBuildRequestA0 {
197    pub root: Node,
198    #[serde(rename = "type")]
199    pub type_: ::std::string::String,
200    pub version: ::std::string::String,
201}