kicad_monkey_contracts/generated/symbol_library_read_result.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///Stable operation diagnostic shared by native, Python, and browser adapters.
28///
29/// <details><summary>JSON schema</summary>
30///
31/// ```json
32///{
33/// "description": "Stable operation diagnostic shared by native, Python, and browser adapters.",
34/// "type": "object",
35/// "required": [
36/// "code",
37/// "message",
38/// "phase"
39/// ],
40/// "properties": {
41/// "code": {
42/// "type": "string"
43/// },
44/// "message": {
45/// "type": "string"
46/// },
47/// "phase": {
48/// "$ref": "#/$defs/DiagnosticPhase"
49/// },
50/// "position": {
51/// "$ref": "#/$defs/SourcePosition"
52/// },
53/// "token": {
54/// "type": "string"
55/// }
56/// },
57/// "additionalProperties": false
58///}
59/// ```
60/// </details>
61#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
62#[serde(deny_unknown_fields)]
63pub struct Diagnostic {
64 pub code: ::std::string::String,
65 pub message: ::std::string::String,
66 pub phase: DiagnosticPhase,
67 #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
68 pub position: ::std::option::Option<SourcePosition>,
69 #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
70 pub token: ::std::option::Option<::std::string::String>,
71}
72///`DiagnosticPhase`
73///
74/// <details><summary>JSON schema</summary>
75///
76/// ```json
77///{
78/// "type": "string",
79/// "enum": [
80/// "lex",
81/// "tree",
82/// "build"
83/// ]
84///}
85/// ```
86/// </details>
87#[derive(
88 ::serde::Deserialize,
89 ::serde::Serialize,
90 Clone,
91 Copy,
92 Debug,
93 Eq,
94 Hash,
95 Ord,
96 PartialEq,
97 PartialOrd,
98)]
99pub enum DiagnosticPhase {
100 #[serde(rename = "lex")]
101 Lex,
102 #[serde(rename = "tree")]
103 Tree,
104 #[serde(rename = "build")]
105 Build,
106}
107impl ::std::fmt::Display for DiagnosticPhase {
108 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
109 match *self {
110 Self::Lex => f.write_str("lex"),
111 Self::Tree => f.write_str("tree"),
112 Self::Build => f.write_str("build"),
113 }
114 }
115}
116impl ::std::str::FromStr for DiagnosticPhase {
117 type Err = self::error::ConversionError;
118 fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
119 match value {
120 "lex" => Ok(Self::Lex),
121 "tree" => Ok(Self::Tree),
122 "build" => Ok(Self::Build),
123 _ => Err("invalid value".into()),
124 }
125 }
126}
127impl ::std::convert::TryFrom<&str> for DiagnosticPhase {
128 type Error = self::error::ConversionError;
129 fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
130 value.parse()
131 }
132}
133impl ::std::convert::TryFrom<&::std::string::String> for DiagnosticPhase {
134 type Error = self::error::ConversionError;
135 fn try_from(
136 value: &::std::string::String,
137 ) -> ::std::result::Result<Self, self::error::ConversionError> {
138 value.parse()
139 }
140}
141impl ::std::convert::TryFrom<::std::string::String> for DiagnosticPhase {
142 type Error = self::error::ConversionError;
143 fn try_from(
144 value: ::std::string::String,
145 ) -> ::std::result::Result<Self, self::error::ConversionError> {
146 value.parse()
147 }
148}
149///Zero-based UTF-8 byte offset with one-based source coordinates.
150///
151/// <details><summary>JSON schema</summary>
152///
153/// ```json
154///{
155/// "description": "Zero-based UTF-8 byte offset with one-based source coordinates.",
156/// "type": "object",
157/// "required": [
158/// "column",
159/// "line",
160/// "offset"
161/// ],
162/// "properties": {
163/// "column": {
164/// "type": "string"
165/// },
166/// "line": {
167/// "type": "string"
168/// },
169/// "offset": {
170/// "type": "string"
171/// }
172/// },
173/// "additionalProperties": false
174///}
175/// ```
176/// </details>
177#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
178#[serde(deny_unknown_fields)]
179pub struct SourcePosition {
180 pub column: ::std::string::String,
181 pub line: ::std::string::String,
182 pub offset: ::std::string::String,
183}
184///Typed symbol-library facts retaining source order.
185///
186/// <details><summary>JSON schema</summary>
187///
188/// ```json
189///{
190/// "$id": "urn:wavenumber:schema:kicad_monkey.symbol_library_read.result:a0",
191/// "title": "Symbol library read result a0",
192/// "description": "Typed symbol-library facts retaining source order.",
193/// "type": "object",
194/// "required": [
195/// "diagnostics",
196/// "source_bytes",
197/// "symbols",
198/// "type",
199/// "version"
200/// ],
201/// "properties": {
202/// "diagnostics": {
203/// "type": "array",
204/// "items": {
205/// "$ref": "#/$defs/Diagnostic"
206/// }
207/// },
208/// "source_bytes": {
209/// "type": "string"
210/// },
211/// "symbols": {
212/// "type": "array",
213/// "items": {
214/// "$ref": "#/$defs/SymbolSummary"
215/// }
216/// },
217/// "type": {
218/// "type": "string",
219/// "const": "kicad_monkey.symbol_library_read.result"
220/// },
221/// "version": {
222/// "type": "string",
223/// "const": "a0"
224/// }
225/// },
226/// "additionalProperties": false
227///}
228/// ```
229/// </details>
230#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
231#[serde(deny_unknown_fields)]
232pub struct SymbolLibraryReadResultA0 {
233 pub diagnostics: ::std::vec::Vec<Diagnostic>,
234 pub source_bytes: ::std::string::String,
235 pub symbols: ::std::vec::Vec<SymbolSummary>,
236 #[serde(rename = "type")]
237 pub type_: ::std::string::String,
238 pub version: ::std::string::String,
239}
240///One source-backed top-level symbol summary.
241///
242/// <details><summary>JSON schema</summary>
243///
244/// ```json
245///{
246/// "description": "One source-backed top-level symbol summary.",
247/// "type": "object",
248/// "required": [
249/// "in_bom",
250/// "name",
251/// "on_board",
252/// "pin_count",
253/// "power",
254/// "property_count",
255/// "subsymbol_count"
256/// ],
257/// "properties": {
258/// "extends": {
259/// "type": "string"
260/// },
261/// "in_bom": {
262/// "type": "boolean"
263/// },
264/// "name": {
265/// "type": "string"
266/// },
267/// "on_board": {
268/// "type": "boolean"
269/// },
270/// "pin_count": {
271/// "type": "integer",
272/// "maximum": 4294967295.0,
273/// "minimum": 0.0
274/// },
275/// "power": {
276/// "type": "boolean"
277/// },
278/// "power_kind": {
279/// "type": "string"
280/// },
281/// "property_count": {
282/// "type": "integer",
283/// "maximum": 4294967295.0,
284/// "minimum": 0.0
285/// },
286/// "subsymbol_count": {
287/// "type": "integer",
288/// "maximum": 4294967295.0,
289/// "minimum": 0.0
290/// }
291/// },
292/// "additionalProperties": false
293///}
294/// ```
295/// </details>
296#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
297#[serde(deny_unknown_fields)]
298pub struct SymbolSummary {
299 #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
300 pub extends: ::std::option::Option<::std::string::String>,
301 pub in_bom: bool,
302 pub name: ::std::string::String,
303 pub on_board: bool,
304 pub pin_count: u32,
305 pub power: bool,
306 #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
307 pub power_kind: ::std::option::Option<::std::string::String>,
308 pub property_count: u32,
309 pub subsymbol_count: u32,
310}