solc_ast_rs_types/types/
event_definition.rs

1use serde::{Deserialize, Serialize};
2
3use crate::types::{ParameterList, SourceLocation, StructuredDocumentation};
4
5#[doc = "EventDefinition"]
6#[doc = r""]
7#[doc = r" <details><summary>JSON schema</summary>"]
8#[doc = r""]
9#[doc = r" ```json"]
10#[doc = "{"]
11#[doc = "  \"type\": \"object\","]
12#[doc = "  \"required\": ["]
13#[doc = "    \"anonymous\","]
14#[doc = "    \"id\","]
15#[doc = "    \"name\","]
16#[doc = "    \"nodeType\","]
17#[doc = "    \"parameters\","]
18#[doc = "    \"src\""]
19#[doc = "  ],"]
20#[doc = "  \"properties\": {"]
21#[doc = "    \"anonymous\": {"]
22#[doc = "      \"type\": \"boolean\""]
23#[doc = "    },"]
24#[doc = "    \"documentation\": {"]
25#[doc = "      \"anyOf\": ["]
26#[doc = "        {"]
27#[doc = "          \"$ref\": \"#/definitions/StructuredDocumentation\""]
28#[doc = "        },"]
29#[doc = "        {"]
30#[doc = "          \"type\": \"null\""]
31#[doc = "        }"]
32#[doc = "      ]"]
33#[doc = "    },"]
34#[doc = "    \"eventSelector\": {"]
35#[doc = "      \"type\": \"string\""]
36#[doc = "    },"]
37#[doc = "    \"id\": {"]
38#[doc = "      \"type\": \"integer\""]
39#[doc = "    },"]
40#[doc = "    \"name\": {"]
41#[doc = "      \"type\": \"string\""]
42#[doc = "    },"]
43#[doc = "    \"nameLocation\": {"]
44#[doc = "      \"type\": \"string\""]
45#[doc = "    },"]
46#[doc = "    \"nodeType\": {"]
47#[doc = "      \"enum\": ["]
48#[doc = "        \"EventDefinition\""]
49#[doc = "      ]"]
50#[doc = "    },"]
51#[doc = "    \"parameters\": {"]
52#[doc = "      \"$ref\": \"#/definitions/ParameterList\""]
53#[doc = "    },"]
54#[doc = "    \"src\": {"]
55#[doc = "      \"$ref\": \"#/definitions/SourceLocation\""]
56#[doc = "    }"]
57#[doc = "  },"]
58#[doc = "  \"additionalProperties\": false"]
59#[doc = "}"]
60#[doc = r" ```"]
61#[doc = r" </details>"]
62#[derive(Clone, Debug, Deserialize, Serialize)]
63pub struct EventDefinition {
64    pub anonymous: bool,
65    #[serde(default, skip_serializing_if = "Option::is_none")]
66    pub documentation: Option<StructuredDocumentation>,
67    #[serde(
68        rename = "eventSelector",
69        default,
70        skip_serializing_if = "Option::is_none"
71    )]
72    pub event_selector: Option<String>,
73    pub id: i64,
74    pub name: String,
75    #[serde(
76        rename = "nameLocation",
77        default,
78        skip_serializing_if = "Option::is_none"
79    )]
80    pub name_location: Option<String>,
81    #[serde(rename = "nodeType")]
82    pub node_type: EventDefinitionNodeType,
83    pub parameters: ParameterList,
84    pub src: SourceLocation,
85}
86
87impl From<&EventDefinition> for EventDefinition {
88    fn from(value: &EventDefinition) -> Self {
89        value.clone()
90    }
91}
92
93// Node Type
94#[doc = "EventDefinitionNodeType"]
95#[doc = r""]
96#[doc = r" <details><summary>JSON schema</summary>"]
97#[doc = r""]
98#[doc = r" ```json"]
99#[doc = "{"]
100#[doc = "  \"enum\": ["]
101#[doc = "    \"EventDefinition\""]
102#[doc = "  ]"]
103#[doc = "}"]
104#[doc = r" ```"]
105#[doc = r" </details>"]
106#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
107pub enum EventDefinitionNodeType {
108    EventDefinition,
109}
110
111impl From<&EventDefinitionNodeType> for EventDefinitionNodeType {
112    fn from(value: &EventDefinitionNodeType) -> Self {
113        value.clone()
114    }
115}
116
117impl ToString for EventDefinitionNodeType {
118    fn to_string(&self) -> String {
119        match *self {
120            Self::EventDefinition => "EventDefinition".to_string(),
121        }
122    }
123}
124
125impl std::str::FromStr for EventDefinitionNodeType {
126    type Err = crate::error::ConversionError;
127    fn from_str(value: &str) -> Result<Self, crate::error::ConversionError> {
128        match value {
129            "EventDefinition" => Ok(Self::EventDefinition),
130            _ => Err("invalid value".into()),
131        }
132    }
133}
134
135impl std::convert::TryFrom<&str> for EventDefinitionNodeType {
136    type Error = crate::error::ConversionError;
137    fn try_from(value: &str) -> Result<Self, crate::error::ConversionError> {
138        value.parse()
139    }
140}
141
142impl std::convert::TryFrom<&String> for EventDefinitionNodeType {
143    type Error = crate::error::ConversionError;
144    fn try_from(value: &String) -> Result<Self, crate::error::ConversionError> {
145        value.parse()
146    }
147}
148
149impl std::convert::TryFrom<String> for EventDefinitionNodeType {
150    type Error = crate::error::ConversionError;
151    fn try_from(value: String) -> Result<Self, crate::error::ConversionError> {
152        value.parse()
153    }
154}