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

kicad_monkey_contracts/generated/
symbol_library_edit_request.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///`SymbolBooleanField`
28///
29/// <details><summary>JSON schema</summary>
30///
31/// ```json
32///{
33///  "type": "string",
34///  "enum": [
35///    "in_bom",
36///    "on_board"
37///  ]
38///}
39/// ```
40/// </details>
41#[derive(
42    ::serde::Deserialize,
43    ::serde::Serialize,
44    Clone,
45    Copy,
46    Debug,
47    Eq,
48    Hash,
49    Ord,
50    PartialEq,
51    PartialOrd,
52)]
53pub enum SymbolBooleanField {
54    #[serde(rename = "in_bom")]
55    InBom,
56    #[serde(rename = "on_board")]
57    OnBoard,
58}
59impl ::std::fmt::Display for SymbolBooleanField {
60    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
61        match *self {
62            Self::InBom => f.write_str("in_bom"),
63            Self::OnBoard => f.write_str("on_board"),
64        }
65    }
66}
67impl ::std::str::FromStr for SymbolBooleanField {
68    type Err = self::error::ConversionError;
69    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
70        match value {
71            "in_bom" => Ok(Self::InBom),
72            "on_board" => Ok(Self::OnBoard),
73            _ => Err("invalid value".into()),
74        }
75    }
76}
77impl ::std::convert::TryFrom<&str> for SymbolBooleanField {
78    type Error = self::error::ConversionError;
79    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
80        value.parse()
81    }
82}
83impl ::std::convert::TryFrom<&::std::string::String> for SymbolBooleanField {
84    type Error = self::error::ConversionError;
85    fn try_from(
86        value: &::std::string::String,
87    ) -> ::std::result::Result<Self, self::error::ConversionError> {
88        value.parse()
89    }
90}
91impl ::std::convert::TryFrom<::std::string::String> for SymbolBooleanField {
92    type Error = self::error::ConversionError;
93    fn try_from(
94        value: ::std::string::String,
95    ) -> ::std::result::Result<Self, self::error::ConversionError> {
96        value.parse()
97    }
98}
99///Focused source-preserving edit of one symbol boolean field.
100///
101/// <details><summary>JSON schema</summary>
102///
103/// ```json
104///{
105///  "$id": "urn:wavenumber:schema:kicad_monkey.symbol_library_edit.request:a0",
106///  "title": "Symbol library edit request a0",
107///  "description": "Focused source-preserving edit of one symbol boolean field.",
108///  "type": "object",
109///  "required": [
110///    "field",
111///    "symbol_name",
112///    "type",
113///    "value",
114///    "version"
115///  ],
116///  "properties": {
117///    "field": {
118///      "$ref": "#/$defs/SymbolBooleanField"
119///    },
120///    "symbol_name": {
121///      "type": "string"
122///    },
123///    "type": {
124///      "type": "string",
125///      "const": "kicad_monkey.symbol_library_edit.request"
126///    },
127///    "value": {
128///      "type": "boolean"
129///    },
130///    "version": {
131///      "type": "string",
132///      "const": "a0"
133///    }
134///  },
135///  "additionalProperties": false
136///}
137/// ```
138/// </details>
139#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
140#[serde(deny_unknown_fields)]
141pub struct SymbolLibraryEditRequestA0 {
142    pub field: SymbolBooleanField,
143    pub symbol_name: ::std::string::String,
144    #[serde(rename = "type")]
145    pub type_: ::std::string::String,
146    pub value: bool,
147    pub version: ::std::string::String,
148}