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

kicad_monkey_contracts/generated/
source_bundle_manifest.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///Canonical decimal wire encoding for an unsigned 64-bit byte count.
28///
29/// <details><summary>JSON schema</summary>
30///
31/// ```json
32///{
33///  "description": "Canonical decimal wire encoding for an unsigned 64-bit byte count.",
34///  "type": "string"
35///}
36/// ```
37/// </details>
38#[derive(
39    ::serde::Deserialize, ::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,
40)]
41#[serde(transparent)]
42pub struct CanonicalUint64Decimal(pub ::std::string::String);
43impl ::std::ops::Deref for CanonicalUint64Decimal {
44    type Target = ::std::string::String;
45    fn deref(&self) -> &::std::string::String {
46        &self.0
47    }
48}
49impl ::std::convert::From<CanonicalUint64Decimal> for ::std::string::String {
50    fn from(value: CanonicalUint64Decimal) -> Self {
51        value.0
52    }
53}
54impl ::std::convert::From<::std::string::String> for CanonicalUint64Decimal {
55    fn from(value: ::std::string::String) -> Self {
56        Self(value)
57    }
58}
59impl ::std::str::FromStr for CanonicalUint64Decimal {
60    type Err = ::std::convert::Infallible;
61    fn from_str(value: &str) -> ::std::result::Result<Self, Self::Err> {
62        Ok(Self(value.to_string()))
63    }
64}
65impl ::std::fmt::Display for CanonicalUint64Decimal {
66    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
67        self.0.fmt(f)
68    }
69}
70///Portable inventory for a named multi-file schematic compiler input.
71///
72/// <details><summary>JSON schema</summary>
73///
74/// ```json
75///{
76///  "$id": "urn:wavenumber:schema:kicad_monkey.source_bundle_manifest:a0",
77///  "title": "Source bundle manifest a0",
78///  "description": "Portable inventory for a named multi-file schematic compiler input.",
79///  "type": "object",
80///  "required": [
81///    "root_schematic_path",
82///    "schema",
83///    "sources",
84///    "type",
85///    "version"
86///  ],
87///  "properties": {
88///    "project_path": {
89///      "type": "string"
90///    },
91///    "root_schematic_path": {
92///      "type": "string"
93///    },
94///    "schema": {
95///      "type": "string",
96///      "const": "kicad_monkey.source_bundle_manifest.a0"
97///    },
98///    "sources": {
99///      "type": "array",
100///      "items": {
101///        "$ref": "#/$defs/SourceBundleSource"
102///      }
103///    },
104///    "type": {
105///      "type": "string",
106///      "const": "kicad_monkey.source_bundle_manifest"
107///    },
108///    "version": {
109///      "type": "string",
110///      "const": "a0"
111///    }
112///  },
113///  "additionalProperties": false
114///}
115/// ```
116/// </details>
117#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
118#[serde(deny_unknown_fields)]
119pub struct SourceBundleManifestA0 {
120    #[serde(
121        default,
122        deserialize_with = "crate::deserialize_present_nonnull",
123        skip_serializing_if = "::std::option::Option::is_none"
124    )]
125    pub project_path: ::std::option::Option<::std::string::String>,
126    pub root_schematic_path: ::std::string::String,
127    pub schema: ::std::string::String,
128    pub sources: ::std::vec::Vec<SourceBundleSource>,
129    #[serde(rename = "type")]
130    pub type_: ::std::string::String,
131    pub version: ::std::string::String,
132}
133///Metadata for one named byte buffer supplied out of band.
134///
135/// <details><summary>JSON schema</summary>
136///
137/// ```json
138///{
139///  "description": "Metadata for one named byte buffer supplied out of band.",
140///  "type": "object",
141///  "required": [
142///    "kind",
143///    "path",
144///    "slot",
145///    "source_bytes"
146///  ],
147///  "properties": {
148///    "kind": {
149///      "$ref": "#/$defs/SourceKind"
150///    },
151///    "path": {
152///      "type": "string"
153///    },
154///    "slot": {
155///      "$ref": "#/$defs/SourceSlot"
156///    },
157///    "source_bytes": {
158///      "$ref": "#/$defs/CanonicalUint64Decimal"
159///    }
160///  },
161///  "additionalProperties": false
162///}
163/// ```
164/// </details>
165#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
166#[serde(deny_unknown_fields)]
167pub struct SourceBundleSource {
168    pub kind: SourceKind,
169    pub path: ::std::string::String,
170    pub slot: SourceSlot,
171    pub source_bytes: CanonicalUint64Decimal,
172}
173///KiCad source role within one schematic compiler input bundle.
174///
175/// <details><summary>JSON schema</summary>
176///
177/// ```json
178///{
179///  "description": "KiCad source role within one schematic compiler input bundle.",
180///  "type": "string",
181///  "enum": [
182///    "project",
183///    "schematic",
184///    "symbol_library",
185///    "symbol_table",
186///    "worksheet",
187///    "other"
188///  ]
189///}
190/// ```
191/// </details>
192#[derive(
193    ::serde::Deserialize,
194    ::serde::Serialize,
195    Clone,
196    Copy,
197    Debug,
198    Eq,
199    Hash,
200    Ord,
201    PartialEq,
202    PartialOrd,
203)]
204pub enum SourceKind {
205    #[serde(rename = "project")]
206    Project,
207    #[serde(rename = "schematic")]
208    Schematic,
209    #[serde(rename = "symbol_library")]
210    SymbolLibrary,
211    #[serde(rename = "symbol_table")]
212    SymbolTable,
213    #[serde(rename = "worksheet")]
214    Worksheet,
215    #[serde(rename = "other")]
216    Other,
217}
218impl ::std::fmt::Display for SourceKind {
219    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
220        match *self {
221            Self::Project => f.write_str("project"),
222            Self::Schematic => f.write_str("schematic"),
223            Self::SymbolLibrary => f.write_str("symbol_library"),
224            Self::SymbolTable => f.write_str("symbol_table"),
225            Self::Worksheet => f.write_str("worksheet"),
226            Self::Other => f.write_str("other"),
227        }
228    }
229}
230impl ::std::str::FromStr for SourceKind {
231    type Err = self::error::ConversionError;
232    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
233        match value {
234            "project" => Ok(Self::Project),
235            "schematic" => Ok(Self::Schematic),
236            "symbol_library" => Ok(Self::SymbolLibrary),
237            "symbol_table" => Ok(Self::SymbolTable),
238            "worksheet" => Ok(Self::Worksheet),
239            "other" => Ok(Self::Other),
240            _ => Err("invalid value".into()),
241        }
242    }
243}
244impl ::std::convert::TryFrom<&str> for SourceKind {
245    type Error = self::error::ConversionError;
246    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
247        value.parse()
248    }
249}
250impl ::std::convert::TryFrom<&::std::string::String> for SourceKind {
251    type Error = self::error::ConversionError;
252    fn try_from(
253        value: &::std::string::String,
254    ) -> ::std::result::Result<Self, self::error::ConversionError> {
255        value.parse()
256    }
257}
258impl ::std::convert::TryFrom<::std::string::String> for SourceKind {
259    type Error = self::error::ConversionError;
260    fn try_from(
261        value: ::std::string::String,
262    ) -> ::std::result::Result<Self, self::error::ConversionError> {
263        value.parse()
264    }
265}
266///Zero-based byte-buffer slot within one manifest.
267///
268/// <details><summary>JSON schema</summary>
269///
270/// ```json
271///{
272///  "description": "Zero-based byte-buffer slot within one manifest.",
273///  "type": "integer",
274///  "maximum": 4294967295.0,
275///  "minimum": 0.0
276///}
277/// ```
278/// </details>
279#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
280#[serde(transparent)]
281pub struct SourceSlot(pub u32);
282impl ::std::ops::Deref for SourceSlot {
283    type Target = u32;
284    fn deref(&self) -> &u32 {
285        &self.0
286    }
287}
288impl ::std::convert::From<SourceSlot> for u32 {
289    fn from(value: SourceSlot) -> Self {
290        value.0
291    }
292}
293impl ::std::convert::From<u32> for SourceSlot {
294    fn from(value: u32) -> Self {
295        Self(value)
296    }
297}
298impl ::std::str::FromStr for SourceSlot {
299    type Err = <u32 as ::std::str::FromStr>::Err;
300    fn from_str(value: &str) -> ::std::result::Result<Self, Self::Err> {
301        Ok(Self(value.parse()?))
302    }
303}
304impl ::std::convert::TryFrom<&str> for SourceSlot {
305    type Error = <u32 as ::std::str::FromStr>::Err;
306    fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
307        value.parse()
308    }
309}
310impl ::std::convert::TryFrom<String> for SourceSlot {
311    type Error = <u32 as ::std::str::FromStr>::Err;
312    fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
313        value.parse()
314    }
315}
316impl ::std::fmt::Display for SourceSlot {
317    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
318        self.0.fmt(f)
319    }
320}