use serde::{Deserialize, Serialize};
pub type RuleSetId = String;
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RuleSet {
pub id: RuleSetId,
#[serde(rename = "loaderId")]
pub loader_id: crate::protocol::network::LoaderId,
#[serde(rename = "sourceText")]
pub source_text: String,
#[serde(
rename = "backendNodeId",
default,
skip_serializing_if = "Option::is_none"
)]
pub backend_node_id: Option<crate::protocol::dom::BackendNodeId>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(rename = "requestId", default, skip_serializing_if = "Option::is_none")]
pub request_id: Option<crate::protocol::network::RequestId>,
#[serde(rename = "errorType", default, skip_serializing_if = "Option::is_none")]
pub error_type: Option<RuleSetErrorType>,
#[serde(
rename = "errorMessage",
default,
skip_serializing_if = "Option::is_none"
)]
pub error_message: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tag: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum RuleSetErrorType {
SourceIsNotJsonObject,
InvalidRulesSkipped,
InvalidRulesetLevelTag,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SpeculationAction {
Prefetch,
Prerender,
PrerenderUntilScript,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SpeculationTargetHint {
Blank,
#[serde(rename = "Self")]
Self_,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PreloadingAttemptKey {
#[serde(rename = "loaderId")]
pub loader_id: crate::protocol::network::LoaderId,
pub action: SpeculationAction,
pub url: String,
#[serde(
rename = "formSubmission",
default,
skip_serializing_if = "Option::is_none"
)]
pub form_submission: Option<bool>,
#[serde(
rename = "targetHint",
default,
skip_serializing_if = "Option::is_none"
)]
pub target_hint: Option<SpeculationTargetHint>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PreloadingAttemptSource {
pub key: PreloadingAttemptKey,
#[serde(rename = "ruleSetIds")]
pub rule_set_ids: Vec<RuleSetId>,
#[serde(rename = "nodeIds")]
pub node_ids: Vec<crate::protocol::dom::BackendNodeId>,
}
pub type PreloadPipelineId = String;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PrerenderFinalStatus {
Activated,
Destroyed,
LowEndDevice,
InvalidSchemeRedirect,
InvalidSchemeNavigation,
NavigationRequestBlockedByCsp,
MojoBinderPolicy,
RendererProcessCrashed,
RendererProcessKilled,
Download,
TriggerDestroyed,
NavigationNotCommitted,
NavigationBadHttpStatus,
ClientCertRequested,
NavigationRequestNetworkError,
CancelAllHostsForTesting,
DidFailLoad,
Stop,
SslCertificateError,
LoginAuthRequested,
UaChangeRequiresReload,
BlockedByClient,
AudioOutputDeviceRequested,
MixedContent,
TriggerBackgrounded,
MemoryLimitExceeded,
DataSaverEnabled,
TriggerUrlHasEffectiveUrl,
ActivatedBeforeStarted,
InactivePageRestriction,
StartFailed,
TimeoutBackgrounded,
CrossSiteRedirectInInitialNavigation,
CrossSiteNavigationInInitialNavigation,
SameSiteCrossOriginRedirectNotOptInInInitialNavigation,
SameSiteCrossOriginNavigationNotOptInInInitialNavigation,
ActivationNavigationParameterMismatch,
ActivatedInBackground,
EmbedderHostDisallowed,
ActivationNavigationDestroyedBeforeSuccess,
TabClosedByUserGesture,
TabClosedWithoutUserGesture,
PrimaryMainFrameRendererProcessCrashed,
PrimaryMainFrameRendererProcessKilled,
ActivationFramePolicyNotCompatible,
PreloadingDisabled,
BatterySaverEnabled,
ActivatedDuringMainFrameNavigation,
PreloadingUnsupportedByWebContents,
CrossSiteRedirectInMainFrameNavigation,
CrossSiteNavigationInMainFrameNavigation,
SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation,
SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation,
MemoryPressureOnTrigger,
MemoryPressureAfterTriggered,
PrerenderingDisabledByDevTools,
SpeculationRuleRemoved,
ActivatedWithAuxiliaryBrowsingContexts,
MaxNumOfRunningEagerPrerendersExceeded,
MaxNumOfRunningNonEagerPrerendersExceeded,
MaxNumOfRunningEmbedderPrerendersExceeded,
PrerenderingUrlHasEffectiveUrl,
RedirectedPrerenderingUrlHasEffectiveUrl,
ActivationUrlHasEffectiveUrl,
JavaScriptInterfaceAdded,
JavaScriptInterfaceRemoved,
AllPrerenderingCanceled,
WindowClosed,
SlowNetwork,
OtherPrerenderedPageActivated,
V8OptimizerDisabled,
PrerenderFailedDuringPrefetch,
BrowsingDataRemoved,
PrerenderHostReused,
FormSubmitWhenPrerendering,
CrossDocumentRestart,
PrefetchFailedCrossOriginSubframe,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PreloadingStatus {
Pending,
Running,
Ready,
Success,
Failure,
NotSupported,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PrefetchStatus {
PrefetchAllowed,
PrefetchFailedIneligibleRedirect,
PrefetchFailedInvalidRedirect,
#[serde(rename = "PrefetchFailedMIMENotSupported")]
PrefetchFailedMimeNotSupported,
PrefetchFailedNetError,
#[serde(rename = "PrefetchFailedNon2XX")]
PrefetchFailedNon2Xx,
PrefetchEvictedAfterBrowsingDataRemoved,
PrefetchEvictedAfterCandidateRemoved,
PrefetchEvictedForNewerPrefetch,
PrefetchHeldback,
PrefetchIneligibleRetryAfter,
PrefetchIsPrivacyDecoy,
PrefetchIsStale,
PrefetchNotEligibleBlockedByConnectionAllowlist,
PrefetchNotEligibleBrowserContextOffTheRecord,
PrefetchNotEligibleCrossOrigin,
PrefetchNotEligibleDataSaverEnabled,
PrefetchNotEligibleExistingProxy,
PrefetchNotEligibleHostIsNonUnique,
PrefetchNotEligibleNonDefaultStoragePartition,
PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy,
PrefetchNotEligibleSchemeIsNotHttps,
PrefetchNotEligibleUserHasCookies,
PrefetchNotEligibleUserHasServiceWorker,
PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler,
PrefetchNotEligibleRedirectFromServiceWorker,
PrefetchNotEligibleRedirectToServiceWorker,
PrefetchNotEligibleBatterySaverEnabled,
PrefetchNotEligiblePreloadingDisabled,
PrefetchNotFinishedInTime,
PrefetchNotStarted,
PrefetchNotUsedCookiesChanged,
PrefetchProxyNotAvailable,
PrefetchResponseUsed,
PrefetchSuccessfulButNotUsed,
PrefetchNotUsedProbeFailed,
PrefetchCancelledOnUserNavigation,
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PrerenderMismatchedHeaders {
#[serde(rename = "headerName")]
pub header_name: String,
#[serde(
rename = "initialValue",
default,
skip_serializing_if = "Option::is_none"
)]
pub initial_value: Option<String>,
#[serde(
rename = "activationValue",
default,
skip_serializing_if = "Option::is_none"
)]
pub activation_value: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}
impl crate::typed::Command for EnableParams {
const METHOD: &'static str = "Preload.enable";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}
impl crate::typed::Command for DisableParams {
const METHOD: &'static str = "Preload.disable";
type Returns = crate::typed::NoReturns;
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RuleSetUpdatedEvent {
#[serde(rename = "ruleSet")]
pub rule_set: RuleSet,
}
impl crate::typed::Event for RuleSetUpdatedEvent {
const METHOD: &'static str = "Preload.ruleSetUpdated";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RuleSetRemovedEvent {
pub id: RuleSetId,
}
impl crate::typed::Event for RuleSetRemovedEvent {
const METHOD: &'static str = "Preload.ruleSetRemoved";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PreloadEnabledStateUpdatedEvent {
#[serde(rename = "disabledByPreference")]
pub disabled_by_preference: bool,
#[serde(rename = "disabledByDataSaver")]
pub disabled_by_data_saver: bool,
#[serde(rename = "disabledByBatterySaver")]
pub disabled_by_battery_saver: bool,
#[serde(rename = "disabledByHoldbackPrefetchSpeculationRules")]
pub disabled_by_holdback_prefetch_speculation_rules: bool,
#[serde(rename = "disabledByHoldbackPrerenderSpeculationRules")]
pub disabled_by_holdback_prerender_speculation_rules: bool,
}
impl crate::typed::Event for PreloadEnabledStateUpdatedEvent {
const METHOD: &'static str = "Preload.preloadEnabledStateUpdated";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PrefetchStatusUpdatedEvent {
pub key: PreloadingAttemptKey,
#[serde(rename = "pipelineId")]
pub pipeline_id: PreloadPipelineId,
#[serde(rename = "initiatingFrameId")]
pub initiating_frame_id: crate::protocol::page::FrameId,
#[serde(rename = "prefetchUrl")]
pub prefetch_url: String,
pub status: PreloadingStatus,
#[serde(rename = "prefetchStatus")]
pub prefetch_status: PrefetchStatus,
#[serde(rename = "requestId")]
pub request_id: crate::protocol::network::RequestId,
}
impl crate::typed::Event for PrefetchStatusUpdatedEvent {
const METHOD: &'static str = "Preload.prefetchStatusUpdated";
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PrerenderStatusUpdatedEvent {
pub key: PreloadingAttemptKey,
#[serde(rename = "pipelineId")]
pub pipeline_id: PreloadPipelineId,
pub status: PreloadingStatus,
#[serde(
rename = "effectiveAction",
default,
skip_serializing_if = "Option::is_none"
)]
pub effective_action: Option<SpeculationAction>,
#[serde(
rename = "prerenderStatus",
default,
skip_serializing_if = "Option::is_none"
)]
pub prerender_status: Option<PrerenderFinalStatus>,
#[serde(
rename = "disallowedMojoInterface",
default,
skip_serializing_if = "Option::is_none"
)]
pub disallowed_mojo_interface: Option<String>,
#[serde(
rename = "mismatchedHeaders",
default,
skip_serializing_if = "Option::is_none"
)]
pub mismatched_headers: Option<Vec<PrerenderMismatchedHeaders>>,
}
impl crate::typed::Event for PrerenderStatusUpdatedEvent {
const METHOD: &'static str = "Preload.prerenderStatusUpdated";
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PreloadingAttemptSourcesUpdatedEvent {
#[serde(rename = "loaderId")]
pub loader_id: crate::protocol::network::LoaderId,
#[serde(rename = "preloadingAttemptSources")]
pub preloading_attempt_sources: Vec<PreloadingAttemptSource>,
}
impl crate::typed::Event for PreloadingAttemptSourcesUpdatedEvent {
const METHOD: &'static str = "Preload.preloadingAttemptSourcesUpdated";
}