use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum ServiceName {
#[default]
BackgroundFetch,
BackgroundSync,
PushMessaging,
Notifications,
PaymentHandler,
PeriodicBackgroundSync,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct EventMetadata {
pub key: String,
pub value: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct BackgroundServiceEvent {
pub timestamp: crate::network::TimeSinceEpoch,
pub origin: String,
pub serviceWorkerRegistrationId: crate::serviceworker::RegistrationID,
pub service: ServiceName,
pub eventName: String,
pub instanceId: String,
pub eventMetadata: Vec<EventMetadata>,
pub storageKey: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct StartObservingParams {
pub service: ServiceName,
}
impl StartObservingParams { pub const METHOD: &'static str = "BackgroundService.startObserving"; }
impl crate::CdpCommand for StartObservingParams {
const METHOD: &'static str = "BackgroundService.startObserving";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct StopObservingParams {
pub service: ServiceName,
}
impl StopObservingParams { pub const METHOD: &'static str = "BackgroundService.stopObserving"; }
impl crate::CdpCommand for StopObservingParams {
const METHOD: &'static str = "BackgroundService.stopObserving";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetRecordingParams {
pub shouldRecord: bool,
pub service: ServiceName,
}
impl SetRecordingParams { pub const METHOD: &'static str = "BackgroundService.setRecording"; }
impl crate::CdpCommand for SetRecordingParams {
const METHOD: &'static str = "BackgroundService.setRecording";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ClearEventsParams {
pub service: ServiceName,
}
impl ClearEventsParams { pub const METHOD: &'static str = "BackgroundService.clearEvents"; }
impl crate::CdpCommand for ClearEventsParams {
const METHOD: &'static str = "BackgroundService.clearEvents";
type Response = crate::EmptyReturns;
}