Skip to main content

cdp_protocol/
background_service.rs

1// Auto-generated from Chrome at version 146.0.7680.165 domain: BackgroundService
2#![allow(dead_code)]
3use super::network;
4use super::service_worker;
5#[allow(unused_imports)]
6use super::types::*;
7#[allow(unused_imports)]
8use derive_builder::Builder;
9#[allow(unused_imports)]
10use serde::{Deserialize, Serialize};
11#[allow(unused_imports)]
12use serde_json::Value as Json;
13#[allow(deprecated)]
14#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
15pub enum ServiceName {
16    #[serde(rename = "backgroundFetch")]
17    BackgroundFetch,
18    #[serde(rename = "backgroundSync")]
19    BackgroundSync,
20    #[serde(rename = "pushMessaging")]
21    PushMessaging,
22    #[serde(rename = "notifications")]
23    Notifications,
24    #[serde(rename = "paymentHandler")]
25    PaymentHandler,
26    #[serde(rename = "periodicBackgroundSync")]
27    PeriodicBackgroundSync,
28}
29#[allow(deprecated)]
30#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
31#[builder(setter(into, strip_option))]
32#[serde(rename_all = "camelCase")]
33#[doc = "A key-value pair for additional event information to pass along."]
34pub struct EventMetadata {
35    #[serde(default)]
36    pub key: String,
37    #[serde(default)]
38    pub value: String,
39}
40#[allow(deprecated)]
41#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
42#[builder(setter(into, strip_option))]
43#[serde(rename_all = "camelCase")]
44pub struct BackgroundServiceEvent {
45    #[doc = "Timestamp of the event (in seconds)."]
46    pub timestamp: network::TimeSinceEpoch,
47    #[serde(default)]
48    #[doc = "The origin this event belongs to."]
49    pub origin: String,
50    #[doc = "The Service Worker ID that initiated the event."]
51    pub service_worker_registration_id: service_worker::RegistrationId,
52    #[doc = "The Background Service this event belongs to."]
53    pub service: ServiceName,
54    #[serde(default)]
55    #[doc = "A description of the event."]
56    pub event_name: String,
57    #[serde(default)]
58    #[doc = "An identifier that groups related events together."]
59    pub instance_id: String,
60    #[doc = "A list of event-specific information."]
61    pub event_metadata: Vec<EventMetadata>,
62    #[serde(default)]
63    #[doc = "Storage key this event belongs to."]
64    pub storage_key: String,
65}
66#[allow(deprecated)]
67#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
68#[builder(setter(into, strip_option))]
69#[serde(rename_all = "camelCase")]
70#[doc = "Enables event updates for the service."]
71pub struct StartObserving {
72    pub service: ServiceName,
73}
74#[allow(deprecated)]
75#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
76#[builder(setter(into, strip_option))]
77#[serde(rename_all = "camelCase")]
78#[doc = "Disables event updates for the service."]
79pub struct StopObserving {
80    pub service: ServiceName,
81}
82#[allow(deprecated)]
83#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
84#[builder(setter(into, strip_option))]
85#[serde(rename_all = "camelCase")]
86#[doc = "Set the recording state for the service."]
87pub struct SetRecording {
88    #[serde(default)]
89    pub should_record: bool,
90    pub service: ServiceName,
91}
92#[allow(deprecated)]
93#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
94#[builder(setter(into, strip_option))]
95#[serde(rename_all = "camelCase")]
96#[doc = "Clears all stored data for the service."]
97pub struct ClearEvents {
98    pub service: ServiceName,
99}
100#[allow(deprecated)]
101#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
102#[doc = "Enables event updates for the service."]
103pub struct StartObservingReturnObject(pub Option<Json>);
104#[allow(deprecated)]
105#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
106#[doc = "Disables event updates for the service."]
107pub struct StopObservingReturnObject(pub Option<Json>);
108#[allow(deprecated)]
109#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
110#[doc = "Set the recording state for the service."]
111pub struct SetRecordingReturnObject(pub Option<Json>);
112#[allow(deprecated)]
113#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
114#[doc = "Clears all stored data for the service."]
115pub struct ClearEventsReturnObject(pub Option<Json>);
116#[allow(deprecated)]
117impl Method for StartObserving {
118    const NAME: &'static str = "BackgroundService.startObserving";
119    type ReturnObject = StartObservingReturnObject;
120}
121#[allow(deprecated)]
122impl Method for StopObserving {
123    const NAME: &'static str = "BackgroundService.stopObserving";
124    type ReturnObject = StopObservingReturnObject;
125}
126#[allow(deprecated)]
127impl Method for SetRecording {
128    const NAME: &'static str = "BackgroundService.setRecording";
129    type ReturnObject = SetRecordingReturnObject;
130}
131#[allow(deprecated)]
132impl Method for ClearEvents {
133    const NAME: &'static str = "BackgroundService.clearEvents";
134    type ReturnObject = ClearEventsReturnObject;
135}
136#[allow(dead_code)]
137pub mod events {
138    #[allow(unused_imports)]
139    use super::super::types::*;
140    #[allow(unused_imports)]
141    use derive_builder::Builder;
142    #[allow(unused_imports)]
143    use serde::{Deserialize, Serialize};
144    #[allow(unused_imports)]
145    use serde_json::Value as Json;
146    #[allow(deprecated)]
147    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
148    pub struct RecordingStateChangedEvent {
149        pub params: RecordingStateChangedEventParams,
150    }
151    #[allow(deprecated)]
152    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
153    #[serde(rename_all = "camelCase")]
154    pub struct RecordingStateChangedEventParams {
155        #[serde(default)]
156        pub is_recording: bool,
157        pub service: super::ServiceName,
158    }
159    #[allow(deprecated)]
160    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
161    pub struct BackgroundServiceEventReceivedEvent {
162        pub params: BackgroundServiceEventReceivedEventParams,
163    }
164    #[allow(deprecated)]
165    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
166    #[serde(rename_all = "camelCase")]
167    pub struct BackgroundServiceEventReceivedEventParams {
168        pub background_service_event: super::BackgroundServiceEvent,
169    }
170}