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

kicad_monkey_contracts/generated/
footprint_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///Metadata paired with a separate kicad.plotter_ir.a0 JSON byte buffer.
158///
159/// <details><summary>JSON schema</summary>
160///
161/// ```json
162///{
163///  "$id": "urn:wavenumber:schema:kicad_monkey.footprint_plot.result:a0",
164///  "title": "Footprint plot result a0",
165///  "description": "Metadata paired with a separate kicad.plotter_ir.a0 JSON byte buffer.",
166///  "type": "object",
167///  "required": [
168///    "diagnostics",
169///    "output_bytes",
170///    "total_operations",
171///    "type",
172///    "version"
173///  ],
174///  "properties": {
175///    "diagnostics": {
176///      "type": "array",
177///      "items": {
178///        "$ref": "#/$defs/Diagnostic"
179///      }
180///    },
181///    "output_bytes": {
182///      "type": "string"
183///    },
184///    "total_operations": {
185///      "type": "integer",
186///      "maximum": 4294967295.0,
187///      "minimum": 0.0
188///    },
189///    "type": {
190///      "type": "string",
191///      "const": "kicad_monkey.footprint_plot.result"
192///    },
193///    "version": {
194///      "type": "string",
195///      "const": "a0"
196///    }
197///  },
198///  "additionalProperties": false
199///}
200/// ```
201/// </details>
202#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
203#[serde(deny_unknown_fields)]
204pub struct FootprintPlotResultA0 {
205    pub diagnostics: ::std::vec::Vec<Diagnostic>,
206    pub output_bytes: ::std::string::String,
207    pub total_operations: u32,
208    #[serde(rename = "type")]
209    pub type_: ::std::string::String,
210    pub version: ::std::string::String,
211}
212///Zero-based UTF-8 byte offset with one-based source coordinates.
213///
214/// <details><summary>JSON schema</summary>
215///
216/// ```json
217///{
218///  "description": "Zero-based UTF-8 byte offset with one-based source coordinates.",
219///  "type": "object",
220///  "required": [
221///    "column",
222///    "line",
223///    "offset"
224///  ],
225///  "properties": {
226///    "column": {
227///      "type": "string"
228///    },
229///    "line": {
230///      "type": "string"
231///    },
232///    "offset": {
233///      "type": "string"
234///    }
235///  },
236///  "additionalProperties": false
237///}
238/// ```
239/// </details>
240#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
241#[serde(deny_unknown_fields)]
242pub struct SourcePosition {
243    pub column: ::std::string::String,
244    pub line: ::std::string::String,
245    pub offset: ::std::string::String,
246}