Skip to main content

rustenium_cdp_definitions/browser_protocol/service_worker/
commands.rs

1use serde::{Deserialize, Serialize};
2#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
3pub struct DeliverPushMessageParams {
4    #[serde(rename = "origin")]
5    pub origin: String,
6    #[serde(rename = "registrationId")]
7    pub registration_id: super::types::RegistrationId,
8    #[serde(rename = "data")]
9    pub data: String,
10}
11impl DeliverPushMessageParams {
12    pub fn new(
13        origin: impl Into<String>,
14        registration_id: impl Into<super::types::RegistrationId>,
15        data: impl Into<String>,
16    ) -> Self {
17        Self {
18            origin: origin.into(),
19            registration_id: registration_id.into(),
20            data: data.into(),
21        }
22    }
23}
24#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
25pub enum DeliverPushMessageMethod {
26    #[serde(rename = "ServiceWorker.deliverPushMessage")]
27    DeliverPushMessage,
28}
29#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
30pub struct DeliverPushMessage {
31    pub method: DeliverPushMessageMethod,
32    pub params: DeliverPushMessageParams,
33}
34impl DeliverPushMessage {
35    pub const IDENTIFIER: &'static str = "ServiceWorker.deliverPushMessage";
36    pub fn identifier(&self) -> &'static str {
37        Self::IDENTIFIER
38    }
39}
40impl crate::CommandResult for DeliverPushMessage {
41    type Result = super::results::DeliverPushMessageResult;
42}
43#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
44pub struct DisableParams {}
45#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
46pub enum DisableMethod {
47    #[serde(rename = "ServiceWorker.disable")]
48    Disable,
49}
50#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
51pub struct Disable {
52    pub method: DisableMethod,
53    pub params: DisableParams,
54}
55impl Disable {
56    pub const IDENTIFIER: &'static str = "ServiceWorker.disable";
57    pub fn identifier(&self) -> &'static str {
58        Self::IDENTIFIER
59    }
60}
61impl crate::CommandResult for Disable {
62    type Result = super::results::DisableResult;
63}
64#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
65pub struct DispatchSyncEventParams {
66    #[serde(rename = "origin")]
67    pub origin: String,
68    #[serde(rename = "registrationId")]
69    pub registration_id: super::types::RegistrationId,
70    #[serde(rename = "tag")]
71    pub tag: String,
72    #[serde(rename = "lastChance")]
73    pub last_chance: bool,
74}
75impl DispatchSyncEventParams {
76    pub fn new(
77        origin: impl Into<String>,
78        registration_id: impl Into<super::types::RegistrationId>,
79        tag: impl Into<String>,
80        last_chance: impl Into<bool>,
81    ) -> Self {
82        Self {
83            origin: origin.into(),
84            registration_id: registration_id.into(),
85            tag: tag.into(),
86            last_chance: last_chance.into(),
87        }
88    }
89}
90#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
91pub enum DispatchSyncEventMethod {
92    #[serde(rename = "ServiceWorker.dispatchSyncEvent")]
93    DispatchSyncEvent,
94}
95#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
96pub struct DispatchSyncEvent {
97    pub method: DispatchSyncEventMethod,
98    pub params: DispatchSyncEventParams,
99}
100impl DispatchSyncEvent {
101    pub const IDENTIFIER: &'static str = "ServiceWorker.dispatchSyncEvent";
102    pub fn identifier(&self) -> &'static str {
103        Self::IDENTIFIER
104    }
105}
106impl crate::CommandResult for DispatchSyncEvent {
107    type Result = super::results::DispatchSyncEventResult;
108}
109#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
110pub struct DispatchPeriodicSyncEventParams {
111    #[serde(rename = "origin")]
112    pub origin: String,
113    #[serde(rename = "registrationId")]
114    pub registration_id: super::types::RegistrationId,
115    #[serde(rename = "tag")]
116    pub tag: String,
117}
118impl DispatchPeriodicSyncEventParams {
119    pub fn new(
120        origin: impl Into<String>,
121        registration_id: impl Into<super::types::RegistrationId>,
122        tag: impl Into<String>,
123    ) -> Self {
124        Self {
125            origin: origin.into(),
126            registration_id: registration_id.into(),
127            tag: tag.into(),
128        }
129    }
130}
131#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
132pub enum DispatchPeriodicSyncEventMethod {
133    #[serde(rename = "ServiceWorker.dispatchPeriodicSyncEvent")]
134    DispatchPeriodicSyncEvent,
135}
136#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
137pub struct DispatchPeriodicSyncEvent {
138    pub method: DispatchPeriodicSyncEventMethod,
139    pub params: DispatchPeriodicSyncEventParams,
140}
141impl DispatchPeriodicSyncEvent {
142    pub const IDENTIFIER: &'static str = "ServiceWorker.dispatchPeriodicSyncEvent";
143    pub fn identifier(&self) -> &'static str {
144        Self::IDENTIFIER
145    }
146}
147impl crate::CommandResult for DispatchPeriodicSyncEvent {
148    type Result = super::results::DispatchPeriodicSyncEventResult;
149}
150#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
151pub struct EnableParams {}
152#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
153pub enum EnableMethod {
154    #[serde(rename = "ServiceWorker.enable")]
155    Enable,
156}
157#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
158pub struct Enable {
159    pub method: EnableMethod,
160    pub params: EnableParams,
161}
162impl Enable {
163    pub const IDENTIFIER: &'static str = "ServiceWorker.enable";
164    pub fn identifier(&self) -> &'static str {
165        Self::IDENTIFIER
166    }
167}
168impl crate::CommandResult for Enable {
169    type Result = super::results::EnableResult;
170}
171#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
172pub struct SetForceUpdateOnPageLoadParams {
173    #[serde(rename = "forceUpdateOnPageLoad")]
174    pub force_update_on_page_load: bool,
175}
176impl SetForceUpdateOnPageLoadParams {
177    pub fn new(force_update_on_page_load: impl Into<bool>) -> Self {
178        Self {
179            force_update_on_page_load: force_update_on_page_load.into(),
180        }
181    }
182}
183#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
184pub enum SetForceUpdateOnPageLoadMethod {
185    #[serde(rename = "ServiceWorker.setForceUpdateOnPageLoad")]
186    SetForceUpdateOnPageLoad,
187}
188#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
189pub struct SetForceUpdateOnPageLoad {
190    pub method: SetForceUpdateOnPageLoadMethod,
191    pub params: SetForceUpdateOnPageLoadParams,
192}
193impl SetForceUpdateOnPageLoad {
194    pub const IDENTIFIER: &'static str = "ServiceWorker.setForceUpdateOnPageLoad";
195    pub fn identifier(&self) -> &'static str {
196        Self::IDENTIFIER
197    }
198}
199impl crate::CommandResult for SetForceUpdateOnPageLoad {
200    type Result = super::results::SetForceUpdateOnPageLoadResult;
201}
202#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
203pub struct SkipWaitingParams {
204    #[serde(rename = "scopeURL")]
205    pub scope_url: String,
206}
207impl SkipWaitingParams {
208    pub fn new(scope_url: impl Into<String>) -> Self {
209        Self {
210            scope_url: scope_url.into(),
211        }
212    }
213}
214impl<T: Into<String>> From<T> for SkipWaitingParams {
215    fn from(url: T) -> Self {
216        SkipWaitingParams::new(url)
217    }
218}
219#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
220pub enum SkipWaitingMethod {
221    #[serde(rename = "ServiceWorker.skipWaiting")]
222    SkipWaiting,
223}
224#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
225pub struct SkipWaiting {
226    pub method: SkipWaitingMethod,
227    pub params: SkipWaitingParams,
228}
229impl SkipWaiting {
230    pub const IDENTIFIER: &'static str = "ServiceWorker.skipWaiting";
231    pub fn identifier(&self) -> &'static str {
232        Self::IDENTIFIER
233    }
234}
235impl crate::CommandResult for SkipWaiting {
236    type Result = super::results::SkipWaitingResult;
237}
238#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
239pub struct StartWorkerParams {
240    #[serde(rename = "scopeURL")]
241    pub scope_url: String,
242}
243impl StartWorkerParams {
244    pub fn new(scope_url: impl Into<String>) -> Self {
245        Self {
246            scope_url: scope_url.into(),
247        }
248    }
249}
250impl<T: Into<String>> From<T> for StartWorkerParams {
251    fn from(url: T) -> Self {
252        StartWorkerParams::new(url)
253    }
254}
255#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
256pub enum StartWorkerMethod {
257    #[serde(rename = "ServiceWorker.startWorker")]
258    StartWorker,
259}
260#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
261pub struct StartWorker {
262    pub method: StartWorkerMethod,
263    pub params: StartWorkerParams,
264}
265impl StartWorker {
266    pub const IDENTIFIER: &'static str = "ServiceWorker.startWorker";
267    pub fn identifier(&self) -> &'static str {
268        Self::IDENTIFIER
269    }
270}
271impl crate::CommandResult for StartWorker {
272    type Result = super::results::StartWorkerResult;
273}
274#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
275pub struct StopAllWorkersParams {}
276#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
277pub enum StopAllWorkersMethod {
278    #[serde(rename = "ServiceWorker.stopAllWorkers")]
279    StopAllWorkers,
280}
281#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
282pub struct StopAllWorkers {
283    pub method: StopAllWorkersMethod,
284    pub params: StopAllWorkersParams,
285}
286impl StopAllWorkers {
287    pub const IDENTIFIER: &'static str = "ServiceWorker.stopAllWorkers";
288    pub fn identifier(&self) -> &'static str {
289        Self::IDENTIFIER
290    }
291}
292impl crate::CommandResult for StopAllWorkers {
293    type Result = super::results::StopAllWorkersResult;
294}
295#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
296pub struct StopWorkerParams {
297    #[serde(rename = "versionId")]
298    pub version_id: String,
299}
300impl StopWorkerParams {
301    pub fn new(version_id: impl Into<String>) -> Self {
302        Self {
303            version_id: version_id.into(),
304        }
305    }
306}
307impl<T: Into<String>> From<T> for StopWorkerParams {
308    fn from(url: T) -> Self {
309        StopWorkerParams::new(url)
310    }
311}
312#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
313pub enum StopWorkerMethod {
314    #[serde(rename = "ServiceWorker.stopWorker")]
315    StopWorker,
316}
317#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
318pub struct StopWorker {
319    pub method: StopWorkerMethod,
320    pub params: StopWorkerParams,
321}
322impl StopWorker {
323    pub const IDENTIFIER: &'static str = "ServiceWorker.stopWorker";
324    pub fn identifier(&self) -> &'static str {
325        Self::IDENTIFIER
326    }
327}
328impl crate::CommandResult for StopWorker {
329    type Result = super::results::StopWorkerResult;
330}
331#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
332pub struct UnregisterParams {
333    #[serde(rename = "scopeURL")]
334    pub scope_url: String,
335}
336impl UnregisterParams {
337    pub fn new(scope_url: impl Into<String>) -> Self {
338        Self {
339            scope_url: scope_url.into(),
340        }
341    }
342}
343impl<T: Into<String>> From<T> for UnregisterParams {
344    fn from(url: T) -> Self {
345        UnregisterParams::new(url)
346    }
347}
348#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
349pub enum UnregisterMethod {
350    #[serde(rename = "ServiceWorker.unregister")]
351    Unregister,
352}
353#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
354pub struct Unregister {
355    pub method: UnregisterMethod,
356    pub params: UnregisterParams,
357}
358impl Unregister {
359    pub const IDENTIFIER: &'static str = "ServiceWorker.unregister";
360    pub fn identifier(&self) -> &'static str {
361        Self::IDENTIFIER
362    }
363}
364impl crate::CommandResult for Unregister {
365    type Result = super::results::UnregisterResult;
366}
367#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
368pub struct UpdateRegistrationParams {
369    #[serde(rename = "scopeURL")]
370    pub scope_url: String,
371}
372impl UpdateRegistrationParams {
373    pub fn new(scope_url: impl Into<String>) -> Self {
374        Self {
375            scope_url: scope_url.into(),
376        }
377    }
378}
379impl<T: Into<String>> From<T> for UpdateRegistrationParams {
380    fn from(url: T) -> Self {
381        UpdateRegistrationParams::new(url)
382    }
383}
384#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
385pub enum UpdateRegistrationMethod {
386    #[serde(rename = "ServiceWorker.updateRegistration")]
387    UpdateRegistration,
388}
389#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
390pub struct UpdateRegistration {
391    pub method: UpdateRegistrationMethod,
392    pub params: UpdateRegistrationParams,
393}
394impl UpdateRegistration {
395    pub const IDENTIFIER: &'static str = "ServiceWorker.updateRegistration";
396    pub fn identifier(&self) -> &'static str {
397        Self::IDENTIFIER
398    }
399}
400impl crate::CommandResult for UpdateRegistration {
401    type Result = super::results::UpdateRegistrationResult;
402}
403group_enum ! (ServiceWorkerCommands { DeliverPushMessage (DeliverPushMessage) , Disable (Disable) , DispatchSyncEvent (DispatchSyncEvent) , DispatchPeriodicSyncEvent (DispatchPeriodicSyncEvent) , Enable (Enable) , SetForceUpdateOnPageLoad (SetForceUpdateOnPageLoad) , SkipWaiting (SkipWaiting) , StartWorker (StartWorker) , StopAllWorkers (StopAllWorkers) , StopWorker (StopWorker) , Unregister (Unregister) , UpdateRegistration (UpdateRegistration) } + identifiable);