rustenium_bidi_definitions/browser/
types.rs1use serde::{Deserialize, Serialize};
2#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, Eq, Hash)]
3pub struct ClientWindow(String);
4impl ClientWindow {
5 pub fn new(val: impl Into<String>) -> Self {
6 ClientWindow(val.into())
7 }
8 pub fn inner(&self) -> &String {
9 &self.0
10 }
11}
12impl AsRef<str> for ClientWindow {
13 fn as_ref(&self) -> &str {
14 self.0.as_str()
15 }
16}
17impl From<ClientWindow> for String {
18 fn from(el: ClientWindow) -> String {
19 el.0
20 }
21}
22impl From<String> for ClientWindow {
23 fn from(expr: String) -> Self {
24 ClientWindow(expr)
25 }
26}
27impl ClientWindow {
28 pub const IDENTIFIER: &'static str = "browser.ClientWindow";
29 pub const DOMAIN_DIRECTION: &'static str = "all";
30 pub fn identifier(&self) -> &'static str {
31 Self::IDENTIFIER
32 }
33}
34#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
35pub struct ClientWindowInfo {
36 #[serde(rename = "active")]
37 pub active: bool,
38 #[serde(rename = "clientWindow")]
39 pub client_window: ClientWindow,
40 #[serde(rename = "height")]
41 pub height: u64,
42 #[serde(rename = "state")]
43 pub state: ClientWindowInfoState,
44 #[serde(rename = "width")]
45 pub width: u64,
46 #[serde(rename = "x")]
47 pub x: i64,
48 #[serde(rename = "y")]
49 pub y: i64,
50}
51#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
52pub enum ClientWindowInfoState {
53 #[serde(rename = "fullscreen")]
54 Fullscreen,
55 #[serde(rename = "maximized")]
56 Maximized,
57 #[serde(rename = "minimized")]
58 Minimized,
59 #[serde(rename = "normal")]
60 Normal,
61}
62impl ClientWindowInfo {
63 pub const IDENTIFIER: &'static str = "browser.ClientWindowInfo";
64 pub const DOMAIN_DIRECTION: &'static str = "all";
65 pub fn identifier(&self) -> &'static str {
66 Self::IDENTIFIER
67 }
68}
69#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, Eq, Hash)]
70pub struct UserContext(String);
71impl UserContext {
72 pub fn new(val: impl Into<String>) -> Self {
73 UserContext(val.into())
74 }
75 pub fn inner(&self) -> &String {
76 &self.0
77 }
78}
79impl AsRef<str> for UserContext {
80 fn as_ref(&self) -> &str {
81 self.0.as_str()
82 }
83}
84impl From<UserContext> for String {
85 fn from(el: UserContext) -> String {
86 el.0
87 }
88}
89impl From<String> for UserContext {
90 fn from(expr: String) -> Self {
91 UserContext(expr)
92 }
93}
94impl UserContext {
95 pub const IDENTIFIER: &'static str = "browser.UserContext";
96 pub const DOMAIN_DIRECTION: &'static str = "all";
97 pub fn identifier(&self) -> &'static str {
98 Self::IDENTIFIER
99 }
100}
101#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
102pub struct UserContextInfo {
103 #[serde(rename = "userContext")]
104 pub user_context: UserContext,
105}
106impl UserContextInfo {
107 pub fn new(user_context: impl Into<UserContext>) -> Self {
108 Self {
109 user_context: user_context.into(),
110 }
111 }
112}
113impl UserContextInfo {
114 pub const IDENTIFIER: &'static str = "browser.UserContextInfo";
115 pub const DOMAIN_DIRECTION: &'static str = "all";
116 pub fn identifier(&self) -> &'static str {
117 Self::IDENTIFIER
118 }
119}
120#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum ClientWindowNamedStateClientWindowRectStateUnion {
123 ClientWindowNamedState(ClientWindowNamedState),
124 ClientWindowRectState(ClientWindowRectState),
125}
126impl From<ClientWindowNamedState> for ClientWindowNamedStateClientWindowRectStateUnion {
127 fn from(v: ClientWindowNamedState) -> Self {
128 ClientWindowNamedStateClientWindowRectStateUnion::ClientWindowNamedState(v)
129 }
130}
131impl TryFrom<ClientWindowNamedStateClientWindowRectStateUnion> for ClientWindowNamedState {
132 type Error = ClientWindowNamedStateClientWindowRectStateUnion;
133 fn try_from(e: ClientWindowNamedStateClientWindowRectStateUnion) -> Result<Self, Self::Error> {
134 match e {
135 ClientWindowNamedStateClientWindowRectStateUnion::ClientWindowNamedState(inner) => {
136 Ok(inner)
137 }
138 other => Err(other),
139 }
140 }
141}
142impl From<ClientWindowRectState> for ClientWindowNamedStateClientWindowRectStateUnion {
143 fn from(v: ClientWindowRectState) -> Self {
144 ClientWindowNamedStateClientWindowRectStateUnion::ClientWindowRectState(v)
145 }
146}
147impl TryFrom<ClientWindowNamedStateClientWindowRectStateUnion> for ClientWindowRectState {
148 type Error = ClientWindowNamedStateClientWindowRectStateUnion;
149 fn try_from(e: ClientWindowNamedStateClientWindowRectStateUnion) -> Result<Self, Self::Error> {
150 match e {
151 ClientWindowNamedStateClientWindowRectStateUnion::ClientWindowRectState(inner) => {
152 Ok(inner)
153 }
154 other => Err(other),
155 }
156 }
157}
158#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
159pub struct ClientWindowNamedState {
160 #[serde(rename = "state")]
161 pub state: ClientWindowNamedStateState,
162}
163#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
164pub enum ClientWindowNamedStateState {
165 #[serde(rename = "fullscreen")]
166 Fullscreen,
167 #[serde(rename = "maximized")]
168 Maximized,
169 #[serde(rename = "minimized")]
170 Minimized,
171}
172impl ClientWindowNamedState {
173 pub fn new(state: impl Into<ClientWindowNamedStateState>) -> Self {
174 Self {
175 state: state.into(),
176 }
177 }
178}
179impl ClientWindowNamedState {
180 pub const IDENTIFIER: &'static str = "browser.ClientWindowNamedState";
181 pub const DOMAIN_DIRECTION: &'static str = "remote";
182 pub fn identifier(&self) -> &'static str {
183 Self::IDENTIFIER
184 }
185}
186#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
187pub struct ClientWindowRectState {
188 #[serde(rename = "state")]
189 pub state: ClientWindowRectStateState,
190 #[serde(rename = "width")]
191 #[serde(skip_serializing_if = "Option::is_none")]
192 #[serde(default)]
193 pub width: Option<u64>,
194 #[serde(rename = "height")]
195 #[serde(skip_serializing_if = "Option::is_none")]
196 #[serde(default)]
197 pub height: Option<u64>,
198 #[serde(rename = "x")]
199 #[serde(skip_serializing_if = "Option::is_none")]
200 #[serde(default)]
201 pub x: Option<i64>,
202 #[serde(rename = "y")]
203 #[serde(skip_serializing_if = "Option::is_none")]
204 #[serde(default)]
205 pub y: Option<i64>,
206}
207#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
208pub enum ClientWindowRectStateState {
209 #[serde(rename = "normal")]
210 Normal,
211}
212impl ClientWindowRectState {
213 pub fn new(state: impl Into<ClientWindowRectStateState>) -> Self {
214 Self {
215 state: state.into(),
216 width: None,
217 height: None,
218 x: None,
219 y: None,
220 }
221 }
222}
223impl ClientWindowRectState {
224 pub const IDENTIFIER: &'static str = "browser.ClientWindowRectState";
225 pub const DOMAIN_DIRECTION: &'static str = "remote";
226 pub fn identifier(&self) -> &'static str {
227 Self::IDENTIFIER
228 }
229}
230#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
231#[serde(untagged)]
232pub enum DownloadBehavior {
233 DownloadBehaviorAllowed(DownloadBehaviorAllowed),
234 DownloadBehaviorDenied(DownloadBehaviorDenied),
235}
236impl From<DownloadBehaviorAllowed> for DownloadBehavior {
237 fn from(v: DownloadBehaviorAllowed) -> Self {
238 DownloadBehavior::DownloadBehaviorAllowed(v)
239 }
240}
241impl TryFrom<DownloadBehavior> for DownloadBehaviorAllowed {
242 type Error = DownloadBehavior;
243 fn try_from(e: DownloadBehavior) -> Result<Self, Self::Error> {
244 match e {
245 DownloadBehavior::DownloadBehaviorAllowed(inner) => Ok(inner),
246 other => Err(other),
247 }
248 }
249}
250impl From<DownloadBehaviorDenied> for DownloadBehavior {
251 fn from(v: DownloadBehaviorDenied) -> Self {
252 DownloadBehavior::DownloadBehaviorDenied(v)
253 }
254}
255impl TryFrom<DownloadBehavior> for DownloadBehaviorDenied {
256 type Error = DownloadBehavior;
257 fn try_from(e: DownloadBehavior) -> Result<Self, Self::Error> {
258 match e {
259 DownloadBehavior::DownloadBehaviorDenied(inner) => Ok(inner),
260 other => Err(other),
261 }
262 }
263}
264#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
265pub struct DownloadBehaviorAllowed {
266 #[serde(rename = "type")]
267 pub r#type: DownloadBehaviorAllowedType,
268 #[serde(rename = "destinationFolder")]
269 pub destination_folder: String,
270}
271#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
272pub enum DownloadBehaviorAllowedType {
273 #[serde(rename = "allowed")]
274 Allowed,
275}
276impl DownloadBehaviorAllowed {
277 pub fn new(
278 r#type: impl Into<DownloadBehaviorAllowedType>,
279 destination_folder: impl Into<String>,
280 ) -> Self {
281 Self {
282 r#type: r#type.into(),
283 destination_folder: destination_folder.into(),
284 }
285 }
286}
287impl DownloadBehaviorAllowed {
288 pub const IDENTIFIER: &'static str = "browser.DownloadBehaviorAllowed";
289 pub const DOMAIN_DIRECTION: &'static str = "remote";
290 pub fn identifier(&self) -> &'static str {
291 Self::IDENTIFIER
292 }
293}
294#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
295pub struct DownloadBehaviorDenied {
296 #[serde(rename = "type")]
297 pub r#type: DownloadBehaviorDeniedType,
298}
299#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
300pub enum DownloadBehaviorDeniedType {
301 #[serde(rename = "denied")]
302 Denied,
303}
304impl DownloadBehaviorDenied {
305 pub fn new(r#type: impl Into<DownloadBehaviorDeniedType>) -> Self {
306 Self {
307 r#type: r#type.into(),
308 }
309 }
310}
311impl DownloadBehaviorDenied {
312 pub const IDENTIFIER: &'static str = "browser.DownloadBehaviorDenied";
313 pub const DOMAIN_DIRECTION: &'static str = "remote";
314 pub fn identifier(&self) -> &'static str {
315 Self::IDENTIFIER
316 }
317}