kicad_monkey_contracts/generated/scan_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///One complete selected form in the original UTF-8 byte buffer.
150///
151/// <details><summary>JSON schema</summary>
152///
153/// ```json
154///{
155/// "description": "One complete selected form in the original UTF-8 byte buffer.",
156/// "type": "object",
157/// "required": [
158/// "column",
159/// "depth",
160/// "end_column",
161/// "end_line",
162/// "end_offset",
163/// "line",
164/// "path",
165/// "start_offset"
166/// ],
167/// "properties": {
168/// "column": {
169/// "type": "string"
170/// },
171/// "depth": {
172/// "type": "integer",
173/// "maximum": 4294967295.0,
174/// "minimum": 0.0
175/// },
176/// "end_column": {
177/// "type": "string"
178/// },
179/// "end_line": {
180/// "type": "string"
181/// },
182/// "end_offset": {
183/// "type": "string"
184/// },
185/// "head": {
186/// "type": "string"
187/// },
188/// "line": {
189/// "type": "string"
190/// },
191/// "path": {
192/// "type": "array",
193/// "items": {
194/// "type": "string"
195/// }
196/// },
197/// "start_offset": {
198/// "type": "string"
199/// }
200/// },
201/// "additionalProperties": false
202///}
203/// ```
204/// </details>
205#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
206#[serde(deny_unknown_fields)]
207pub struct FormSpan {
208 pub column: ::std::string::String,
209 pub depth: u32,
210 pub end_column: ::std::string::String,
211 pub end_line: ::std::string::String,
212 pub end_offset: ::std::string::String,
213 #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
214 pub head: ::std::option::Option<::std::string::String>,
215 pub line: ::std::string::String,
216 pub path: ::std::vec::Vec<::std::string::String>,
217 pub start_offset: ::std::string::String,
218}
219///Result envelope; selected source bytes remain in the caller-owned input buffer.
220///
221/// <details><summary>JSON schema</summary>
222///
223/// ```json
224///{
225/// "$id": "urn:wavenumber:schema:kicad_monkey.sexpr_scan.result:a0",
226/// "title": "S-expression scan result a0",
227/// "description": "Result envelope; selected source bytes remain in the caller-owned input buffer.",
228/// "type": "object",
229/// "required": [
230/// "diagnostics",
231/// "forms",
232/// "source_bytes",
233/// "type",
234/// "version"
235/// ],
236/// "properties": {
237/// "diagnostics": {
238/// "type": "array",
239/// "items": {
240/// "$ref": "#/$defs/Diagnostic"
241/// }
242/// },
243/// "forms": {
244/// "type": "array",
245/// "items": {
246/// "$ref": "#/$defs/FormSpan"
247/// }
248/// },
249/// "source_bytes": {
250/// "type": "string"
251/// },
252/// "type": {
253/// "type": "string",
254/// "const": "kicad_monkey.sexpr_scan.result"
255/// },
256/// "version": {
257/// "type": "string",
258/// "const": "a0"
259/// }
260/// },
261/// "additionalProperties": false
262///}
263/// ```
264/// </details>
265#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
266#[serde(deny_unknown_fields)]
267pub struct SExpressionScanResultA0 {
268 pub diagnostics: ::std::vec::Vec<Diagnostic>,
269 pub forms: ::std::vec::Vec<FormSpan>,
270 pub source_bytes: ::std::string::String,
271 #[serde(rename = "type")]
272 pub type_: ::std::string::String,
273 pub version: ::std::string::String,
274}
275///Zero-based UTF-8 byte offset with one-based source coordinates.
276///
277/// <details><summary>JSON schema</summary>
278///
279/// ```json
280///{
281/// "description": "Zero-based UTF-8 byte offset with one-based source coordinates.",
282/// "type": "object",
283/// "required": [
284/// "column",
285/// "line",
286/// "offset"
287/// ],
288/// "properties": {
289/// "column": {
290/// "type": "string"
291/// },
292/// "line": {
293/// "type": "string"
294/// },
295/// "offset": {
296/// "type": "string"
297/// }
298/// },
299/// "additionalProperties": false
300///}
301/// ```
302/// </details>
303#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
304#[serde(deny_unknown_fields)]
305pub struct SourcePosition {
306 pub column: ::std::string::String,
307 pub line: ::std::string::String,
308 pub offset: ::std::string::String,
309}