solidity_language_server/solc_ast/
enums.rs1use std::fmt;
7
8use serde::{Deserialize, Serialize};
9
10#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
16#[serde(rename_all = "lowercase")]
17pub enum ContractKind {
18 Contract,
19 Interface,
20 Library,
21}
22
23impl fmt::Display for ContractKind {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 match self {
26 Self::Contract => write!(f, "contract"),
27 Self::Interface => write!(f, "interface"),
28 Self::Library => write!(f, "library"),
29 }
30 }
31}
32
33#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
39#[serde(rename_all = "lowercase")]
40pub enum Visibility {
41 Default,
42 Private,
43 Internal,
44 Public,
45 External,
46}
47
48impl fmt::Display for Visibility {
49 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50 match self {
51 Self::Default => write!(f, ""),
52 Self::Private => write!(f, "private"),
53 Self::Internal => write!(f, "internal"),
54 Self::Public => write!(f, "public"),
55 Self::External => write!(f, "external"),
56 }
57 }
58}
59
60#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
66#[serde(rename_all = "lowercase")]
67pub enum StateMutability {
68 Pure,
69 View,
70 Nonpayable,
71 Payable,
72}
73
74impl fmt::Display for StateMutability {
75 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
76 match self {
77 Self::Pure => write!(f, "pure"),
78 Self::View => write!(f, "view"),
79 Self::Nonpayable => write!(f, "nonpayable"),
80 Self::Payable => write!(f, "payable"),
81 }
82 }
83}
84
85#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
91#[serde(rename_all = "lowercase")]
92pub enum Mutability {
93 Mutable,
94 Immutable,
95 Constant,
96 Transient,
98}
99
100impl fmt::Display for Mutability {
101 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
102 match self {
103 Self::Mutable => write!(f, "mutable"),
104 Self::Immutable => write!(f, "immutable"),
105 Self::Constant => write!(f, "constant"),
106 Self::Transient => write!(f, "transient"),
107 }
108 }
109}
110
111#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
117#[serde(rename_all = "lowercase")]
118pub enum StorageLocation {
119 Default,
120 Storage,
121 Memory,
122 Calldata,
123 Transient,
125}
126
127impl fmt::Display for StorageLocation {
128 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
129 match self {
130 Self::Default => write!(f, "default"),
131 Self::Storage => write!(f, "storage"),
132 Self::Memory => write!(f, "memory"),
133 Self::Calldata => write!(f, "calldata"),
134 Self::Transient => write!(f, "transient"),
135 }
136 }
137}
138
139#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
145#[serde(rename_all = "camelCase")]
146pub enum FunctionKind {
147 Function,
148 Receive,
149 Constructor,
150 Fallback,
151 FreeFunction,
152}
153
154impl fmt::Display for FunctionKind {
155 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
156 match self {
157 Self::Function => write!(f, "function"),
158 Self::Receive => write!(f, "receive"),
159 Self::Constructor => write!(f, "constructor"),
160 Self::Fallback => write!(f, "fallback"),
161 Self::FreeFunction => write!(f, "function"),
162 }
163 }
164}
165
166#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
170#[serde(rename_all = "camelCase")]
171pub enum FunctionCallKind {
172 FunctionCall,
173 TypeConversion,
174 StructConstructorCall,
175}
176
177#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
181#[serde(rename_all = "camelCase")]
182pub enum LiteralKind {
183 Bool,
184 Number,
185 String,
186 HexString,
187 UnicodeString,
188}
189
190#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
194#[serde(rename_all = "camelCase")]
195pub enum ModifierInvocationKind {
196 ModifierInvocation,
197 BaseConstructorSpecifier,
198}
199
200#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)]
204#[serde(rename_all = "camelCase")]
205pub enum YulLiteralKind {
206 Number,
207 String,
208 Bool,
209}