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

kicad_monkey_contracts/generated/
symbol_plot_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(
68        default,
69        deserialize_with = "crate::deserialize_present_nonnull",
70        skip_serializing_if = "::std::option::Option::is_none"
71    )]
72    pub position: ::std::option::Option<SourcePosition>,
73    #[serde(
74        default,
75        deserialize_with = "crate::deserialize_present_nonnull",
76        skip_serializing_if = "::std::option::Option::is_none"
77    )]
78    pub token: ::std::option::Option<::std::string::String>,
79}
80///`DiagnosticPhase`
81///
82/// <details><summary>JSON schema</summary>
83///
84/// ```json
85///{
86///  "type": "string",
87///  "enum": [
88///    "lex",
89///    "tree",
90///    "build"
91///  ]
92///}
93/// ```
94/// </details>
95#[derive(
96    ::serde::Deserialize,
97    ::serde::Serialize,
98    Clone,
99    Copy,
100    Debug,
101    Eq,
102    Hash,
103    Ord,
104    PartialEq,
105    PartialOrd,
106)]
107pub enum DiagnosticPhase {
108    #[serde(rename = "lex")]
109    Lex,
110    #[serde(rename = "tree")]
111    Tree,
112    #[serde(rename = "build")]
113    Build,
114}
115impl ::std::fmt::Display for DiagnosticPhase {
116    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
117        match *self {
118            Self::Lex => f.write_str("lex"),
119            Self::Tree => f.write_str("tree"),
120            Self::Build => f.write_str("build"),
121        }
122    }
123}
124impl ::std::str::FromStr for DiagnosticPhase {
125    type Err = self::error::ConversionError;
126    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
127        match value {
128            "lex" => Ok(Self::Lex),
129            "tree" => Ok(Self::Tree),
130            "build" => Ok(Self::Build),
131            _ => Err("invalid value".into()),
132        }
133    }
134}
135impl ::std::convert::TryFrom<&str> for DiagnosticPhase {
136    type Error = self::error::ConversionError;
137    fn try_from(value: &str) -> ::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}
149impl ::std::convert::TryFrom<::std::string::String> for DiagnosticPhase {
150    type Error = self::error::ConversionError;
151    fn try_from(
152        value: ::std::string::String,
153    ) -> ::std::result::Result<Self, self::error::ConversionError> {
154        value.parse()
155    }
156}
157///Zero-based UTF-8 byte offset with one-based source coordinates.
158///
159/// <details><summary>JSON schema</summary>
160///
161/// ```json
162///{
163///  "description": "Zero-based UTF-8 byte offset with one-based source coordinates.",
164///  "type": "object",
165///  "required": [
166///    "column",
167///    "line",
168///    "offset"
169///  ],
170///  "properties": {
171///    "column": {
172///      "type": "string"
173///    },
174///    "line": {
175///      "type": "string"
176///    },
177///    "offset": {
178///      "type": "string"
179///    }
180///  },
181///  "additionalProperties": false
182///}
183/// ```
184/// </details>
185#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
186#[serde(deny_unknown_fields)]
187pub struct SourcePosition {
188    pub column: ::std::string::String,
189    pub line: ::std::string::String,
190    pub offset: ::std::string::String,
191}
192///Metadata paired with a separate symbol plotter-IR JSON byte buffer.
193///
194/// <details><summary>JSON schema</summary>
195///
196/// ```json
197///{
198///  "$id": "urn:wavenumber:schema:kicad_monkey.symbol_plot.result:a0",
199///  "title": "Symbol plot result a0",
200///  "description": "Metadata paired with a separate symbol plotter-IR JSON byte buffer.",
201///  "type": "object",
202///  "required": [
203///    "diagnostics",
204///    "output_bytes",
205///    "total_operations",
206///    "type",
207///    "version"
208///  ],
209///  "properties": {
210///    "diagnostics": {
211///      "type": "array",
212///      "items": {
213///        "$ref": "#/$defs/Diagnostic"
214///      }
215///    },
216///    "output_bytes": {
217///      "type": "string"
218///    },
219///    "total_operations": {
220///      "type": "integer",
221///      "maximum": 4294967295.0,
222///      "minimum": 0.0
223///    },
224///    "type": {
225///      "type": "string",
226///      "const": "kicad_monkey.symbol_plot.result"
227///    },
228///    "version": {
229///      "type": "string",
230///      "const": "a0"
231///    }
232///  },
233///  "additionalProperties": false
234///}
235/// ```
236/// </details>
237#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
238#[serde(deny_unknown_fields)]
239pub struct SymbolPlotResultA0 {
240    pub diagnostics: ::std::vec::Vec<Diagnostic>,
241    pub output_bytes: ::std::string::String,
242    pub total_operations: u32,
243    #[serde(rename = "type")]
244    pub type_: ::std::string::String,
245    pub version: ::std::string::String,
246}