#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum PrefetchStatus {
PrefetchAllowed,
PrefetchFailedIneligibleRedirect,
PrefetchFailedInvalidRedirect,
PrefetchFailedMimeNotSupported,
PrefetchFailedNetError,
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,
Unknown(String),
}
impl PrefetchStatus {
pub fn as_str(&self) -> &str {
match self {
Self::PrefetchAllowed => "PrefetchAllowed",
Self::PrefetchFailedIneligibleRedirect => "PrefetchFailedIneligibleRedirect",
Self::PrefetchFailedInvalidRedirect => "PrefetchFailedInvalidRedirect",
Self::PrefetchFailedMimeNotSupported => "PrefetchFailedMIMENotSupported",
Self::PrefetchFailedNetError => "PrefetchFailedNetError",
Self::PrefetchFailedNon2Xx => "PrefetchFailedNon2XX",
Self::PrefetchEvictedAfterBrowsingDataRemoved => {
"PrefetchEvictedAfterBrowsingDataRemoved"
}
Self::PrefetchEvictedAfterCandidateRemoved => "PrefetchEvictedAfterCandidateRemoved",
Self::PrefetchEvictedForNewerPrefetch => "PrefetchEvictedForNewerPrefetch",
Self::PrefetchHeldback => "PrefetchHeldback",
Self::PrefetchIneligibleRetryAfter => "PrefetchIneligibleRetryAfter",
Self::PrefetchIsPrivacyDecoy => "PrefetchIsPrivacyDecoy",
Self::PrefetchIsStale => "PrefetchIsStale",
Self::PrefetchNotEligibleBlockedByConnectionAllowlist => {
"PrefetchNotEligibleBlockedByConnectionAllowlist"
}
Self::PrefetchNotEligibleBrowserContextOffTheRecord => {
"PrefetchNotEligibleBrowserContextOffTheRecord"
}
Self::PrefetchNotEligibleCrossOrigin => "PrefetchNotEligibleCrossOrigin",
Self::PrefetchNotEligibleDataSaverEnabled => "PrefetchNotEligibleDataSaverEnabled",
Self::PrefetchNotEligibleExistingProxy => "PrefetchNotEligibleExistingProxy",
Self::PrefetchNotEligibleHostIsNonUnique => "PrefetchNotEligibleHostIsNonUnique",
Self::PrefetchNotEligibleNonDefaultStoragePartition => {
"PrefetchNotEligibleNonDefaultStoragePartition"
}
Self::PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy => {
"PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy"
}
Self::PrefetchNotEligibleSchemeIsNotHttps => "PrefetchNotEligibleSchemeIsNotHttps",
Self::PrefetchNotEligibleUserHasCookies => "PrefetchNotEligibleUserHasCookies",
Self::PrefetchNotEligibleUserHasServiceWorker => {
"PrefetchNotEligibleUserHasServiceWorker"
}
Self::PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler => {
"PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler"
}
Self::PrefetchNotEligibleRedirectFromServiceWorker => {
"PrefetchNotEligibleRedirectFromServiceWorker"
}
Self::PrefetchNotEligibleRedirectToServiceWorker => {
"PrefetchNotEligibleRedirectToServiceWorker"
}
Self::PrefetchNotEligibleBatterySaverEnabled => {
"PrefetchNotEligibleBatterySaverEnabled"
}
Self::PrefetchNotEligiblePreloadingDisabled => "PrefetchNotEligiblePreloadingDisabled",
Self::PrefetchNotFinishedInTime => "PrefetchNotFinishedInTime",
Self::PrefetchNotStarted => "PrefetchNotStarted",
Self::PrefetchNotUsedCookiesChanged => "PrefetchNotUsedCookiesChanged",
Self::PrefetchProxyNotAvailable => "PrefetchProxyNotAvailable",
Self::PrefetchResponseUsed => "PrefetchResponseUsed",
Self::PrefetchSuccessfulButNotUsed => "PrefetchSuccessfulButNotUsed",
Self::PrefetchNotUsedProbeFailed => "PrefetchNotUsedProbeFailed",
Self::PrefetchCancelledOnUserNavigation => "PrefetchCancelledOnUserNavigation",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for PrefetchStatus {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for PrefetchStatus {
fn from(value: String) -> Self {
match value.as_str() {
"PrefetchAllowed" => PrefetchStatus::PrefetchAllowed,
"PrefetchFailedIneligibleRedirect" => PrefetchStatus::PrefetchFailedIneligibleRedirect,
"PrefetchFailedInvalidRedirect" => PrefetchStatus::PrefetchFailedInvalidRedirect,
"PrefetchFailedMIMENotSupported" => PrefetchStatus::PrefetchFailedMimeNotSupported,
"PrefetchFailedNetError" => PrefetchStatus::PrefetchFailedNetError,
"PrefetchFailedNon2XX" => PrefetchStatus::PrefetchFailedNon2Xx,
"PrefetchEvictedAfterBrowsingDataRemoved" => {
PrefetchStatus::PrefetchEvictedAfterBrowsingDataRemoved
}
"PrefetchEvictedAfterCandidateRemoved" => {
PrefetchStatus::PrefetchEvictedAfterCandidateRemoved
}
"PrefetchEvictedForNewerPrefetch" => PrefetchStatus::PrefetchEvictedForNewerPrefetch,
"PrefetchHeldback" => PrefetchStatus::PrefetchHeldback,
"PrefetchIneligibleRetryAfter" => PrefetchStatus::PrefetchIneligibleRetryAfter,
"PrefetchIsPrivacyDecoy" => PrefetchStatus::PrefetchIsPrivacyDecoy,
"PrefetchIsStale" => PrefetchStatus::PrefetchIsStale,
"PrefetchNotEligibleBlockedByConnectionAllowlist" => {
PrefetchStatus::PrefetchNotEligibleBlockedByConnectionAllowlist
}
"PrefetchNotEligibleBrowserContextOffTheRecord" => {
PrefetchStatus::PrefetchNotEligibleBrowserContextOffTheRecord
}
"PrefetchNotEligibleCrossOrigin" => PrefetchStatus::PrefetchNotEligibleCrossOrigin,
"PrefetchNotEligibleDataSaverEnabled" => {
PrefetchStatus::PrefetchNotEligibleDataSaverEnabled
}
"PrefetchNotEligibleExistingProxy" => PrefetchStatus::PrefetchNotEligibleExistingProxy,
"PrefetchNotEligibleHostIsNonUnique" => {
PrefetchStatus::PrefetchNotEligibleHostIsNonUnique
}
"PrefetchNotEligibleNonDefaultStoragePartition" => {
PrefetchStatus::PrefetchNotEligibleNonDefaultStoragePartition
}
"PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy" => {
PrefetchStatus::PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy
}
"PrefetchNotEligibleSchemeIsNotHttps" => {
PrefetchStatus::PrefetchNotEligibleSchemeIsNotHttps
}
"PrefetchNotEligibleUserHasCookies" => {
PrefetchStatus::PrefetchNotEligibleUserHasCookies
}
"PrefetchNotEligibleUserHasServiceWorker" => {
PrefetchStatus::PrefetchNotEligibleUserHasServiceWorker
}
"PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler" => {
PrefetchStatus::PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler
}
"PrefetchNotEligibleRedirectFromServiceWorker" => {
PrefetchStatus::PrefetchNotEligibleRedirectFromServiceWorker
}
"PrefetchNotEligibleRedirectToServiceWorker" => {
PrefetchStatus::PrefetchNotEligibleRedirectToServiceWorker
}
"PrefetchNotEligibleBatterySaverEnabled" => {
PrefetchStatus::PrefetchNotEligibleBatterySaverEnabled
}
"PrefetchNotEligiblePreloadingDisabled" => {
PrefetchStatus::PrefetchNotEligiblePreloadingDisabled
}
"PrefetchNotFinishedInTime" => PrefetchStatus::PrefetchNotFinishedInTime,
"PrefetchNotStarted" => PrefetchStatus::PrefetchNotStarted,
"PrefetchNotUsedCookiesChanged" => PrefetchStatus::PrefetchNotUsedCookiesChanged,
"PrefetchProxyNotAvailable" => PrefetchStatus::PrefetchProxyNotAvailable,
"PrefetchResponseUsed" => PrefetchStatus::PrefetchResponseUsed,
"PrefetchSuccessfulButNotUsed" => PrefetchStatus::PrefetchSuccessfulButNotUsed,
"PrefetchNotUsedProbeFailed" => PrefetchStatus::PrefetchNotUsedProbeFailed,
"PrefetchCancelledOnUserNavigation" => {
PrefetchStatus::PrefetchCancelledOnUserNavigation
}
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for PrefetchStatus {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for PrefetchStatus {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = PrefetchStatus;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"PrefetchAllowed" => PrefetchStatus::PrefetchAllowed,
"PrefetchFailedIneligibleRedirect" => {
PrefetchStatus::PrefetchFailedIneligibleRedirect
}
"PrefetchFailedInvalidRedirect" => {
PrefetchStatus::PrefetchFailedInvalidRedirect
}
"PrefetchFailedMIMENotSupported" => {
PrefetchStatus::PrefetchFailedMimeNotSupported
}
"PrefetchFailedNetError" => PrefetchStatus::PrefetchFailedNetError,
"PrefetchFailedNon2XX" => PrefetchStatus::PrefetchFailedNon2Xx,
"PrefetchEvictedAfterBrowsingDataRemoved" => {
PrefetchStatus::PrefetchEvictedAfterBrowsingDataRemoved
}
"PrefetchEvictedAfterCandidateRemoved" => {
PrefetchStatus::PrefetchEvictedAfterCandidateRemoved
}
"PrefetchEvictedForNewerPrefetch" => {
PrefetchStatus::PrefetchEvictedForNewerPrefetch
}
"PrefetchHeldback" => PrefetchStatus::PrefetchHeldback,
"PrefetchIneligibleRetryAfter" => PrefetchStatus::PrefetchIneligibleRetryAfter,
"PrefetchIsPrivacyDecoy" => PrefetchStatus::PrefetchIsPrivacyDecoy,
"PrefetchIsStale" => PrefetchStatus::PrefetchIsStale,
"PrefetchNotEligibleBlockedByConnectionAllowlist" => {
PrefetchStatus::PrefetchNotEligibleBlockedByConnectionAllowlist
}
"PrefetchNotEligibleBrowserContextOffTheRecord" => {
PrefetchStatus::PrefetchNotEligibleBrowserContextOffTheRecord
}
"PrefetchNotEligibleCrossOrigin" => {
PrefetchStatus::PrefetchNotEligibleCrossOrigin
}
"PrefetchNotEligibleDataSaverEnabled" => {
PrefetchStatus::PrefetchNotEligibleDataSaverEnabled
}
"PrefetchNotEligibleExistingProxy" => {
PrefetchStatus::PrefetchNotEligibleExistingProxy
}
"PrefetchNotEligibleHostIsNonUnique" => {
PrefetchStatus::PrefetchNotEligibleHostIsNonUnique
}
"PrefetchNotEligibleNonDefaultStoragePartition" => {
PrefetchStatus::PrefetchNotEligibleNonDefaultStoragePartition
}
"PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy" => {
PrefetchStatus::PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy
}
"PrefetchNotEligibleSchemeIsNotHttps" => {
PrefetchStatus::PrefetchNotEligibleSchemeIsNotHttps
}
"PrefetchNotEligibleUserHasCookies" => {
PrefetchStatus::PrefetchNotEligibleUserHasCookies
}
"PrefetchNotEligibleUserHasServiceWorker" => {
PrefetchStatus::PrefetchNotEligibleUserHasServiceWorker
}
"PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler" => {
PrefetchStatus::PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler
}
"PrefetchNotEligibleRedirectFromServiceWorker" => {
PrefetchStatus::PrefetchNotEligibleRedirectFromServiceWorker
}
"PrefetchNotEligibleRedirectToServiceWorker" => {
PrefetchStatus::PrefetchNotEligibleRedirectToServiceWorker
}
"PrefetchNotEligibleBatterySaverEnabled" => {
PrefetchStatus::PrefetchNotEligibleBatterySaverEnabled
}
"PrefetchNotEligiblePreloadingDisabled" => {
PrefetchStatus::PrefetchNotEligiblePreloadingDisabled
}
"PrefetchNotFinishedInTime" => PrefetchStatus::PrefetchNotFinishedInTime,
"PrefetchNotStarted" => PrefetchStatus::PrefetchNotStarted,
"PrefetchNotUsedCookiesChanged" => {
PrefetchStatus::PrefetchNotUsedCookiesChanged
}
"PrefetchProxyNotAvailable" => PrefetchStatus::PrefetchProxyNotAvailable,
"PrefetchResponseUsed" => PrefetchStatus::PrefetchResponseUsed,
"PrefetchSuccessfulButNotUsed" => PrefetchStatus::PrefetchSuccessfulButNotUsed,
"PrefetchNotUsedProbeFailed" => PrefetchStatus::PrefetchNotUsedProbeFailed,
"PrefetchCancelledOnUserNavigation" => {
PrefetchStatus::PrefetchCancelledOnUserNavigation
}
_ => PrefetchStatus::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(PrefetchStatus::from(v))
}
}
d.deserialize_str(Visitor)
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(transparent)]
pub struct PreloadPipelineId(String);
impl PreloadPipelineId {
pub fn new(value: String) -> Self {
Self(value)
}
pub fn into_inner(self) -> String {
self.0
}
pub fn as_str(&self) -> &str {
&self.0
}
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct PreloadingAttemptKey {
#[serde(rename = "loaderId")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub loader_id: crate::network::types::LoaderId,
#[serde(rename = "action")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub action: crate::preload::types::SpeculationAction,
#[serde(rename = "url")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub url: String,
#[serde(rename = "formSubmission")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub form_submission: Option<bool>,
#[serde(rename = "targetHint")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub target_hint: Option<crate::preload::types::SpeculationTargetHint>,
}
impl<'de> serde::Deserialize<'de> for PreloadingAttemptKey {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = PreloadingAttemptKey;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议 object")
}
fn visit_map<A: serde::de::MapAccess<'de>>(
self,
a: A,
) -> Result<Self::Value, A::Error> {
#[derive(serde::Deserialize)]
struct Fields {
#[serde(rename = "loaderId")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub loader_id: crate::network::types::LoaderId,
#[serde(rename = "action")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub action: crate::preload::types::SpeculationAction,
#[serde(rename = "url")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub url: String,
#[serde(rename = "formSubmission")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub form_submission: Option<bool>,
#[serde(rename = "targetHint")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub target_hint: Option<crate::preload::types::SpeculationTargetHint>,
}
let fields = <Fields as serde::Deserialize>::deserialize(
serde::de::value::MapAccessDeserializer::new(a),
)?;
Ok(PreloadingAttemptKey {
loader_id: fields.loader_id,
action: fields.action,
url: fields.url,
form_submission: fields.form_submission,
target_hint: fields.target_hint,
})
}
}
d.deserialize_map(Visitor)
}
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct PreloadingAttemptSource {
#[serde(rename = "key")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub key: crate::preload::types::PreloadingAttemptKey,
#[serde(rename = "ruleSetIds")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub rule_set_ids: Vec<crate::preload::types::RuleSetId>,
#[serde(rename = "nodeIds")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub node_ids: Vec<crate::dom::types::BackendNodeId>,
}
impl<'de> serde::Deserialize<'de> for PreloadingAttemptSource {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = PreloadingAttemptSource;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议 object")
}
fn visit_map<A: serde::de::MapAccess<'de>>(
self,
a: A,
) -> Result<Self::Value, A::Error> {
#[derive(serde::Deserialize)]
struct Fields {
#[serde(rename = "key")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub key: crate::preload::types::PreloadingAttemptKey,
#[serde(rename = "ruleSetIds")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub rule_set_ids: Vec<crate::preload::types::RuleSetId>,
#[serde(rename = "nodeIds")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub node_ids: Vec<crate::dom::types::BackendNodeId>,
}
let fields = <Fields as serde::Deserialize>::deserialize(
serde::de::value::MapAccessDeserializer::new(a),
)?;
Ok(PreloadingAttemptSource {
key: fields.key,
rule_set_ids: fields.rule_set_ids,
node_ids: fields.node_ids,
})
}
}
d.deserialize_map(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum PreloadingStatus {
Pending,
Running,
Ready,
Success,
Failure,
NotSupported,
Unknown(String),
}
impl PreloadingStatus {
pub fn as_str(&self) -> &str {
match self {
Self::Pending => "Pending",
Self::Running => "Running",
Self::Ready => "Ready",
Self::Success => "Success",
Self::Failure => "Failure",
Self::NotSupported => "NotSupported",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for PreloadingStatus {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for PreloadingStatus {
fn from(value: String) -> Self {
match value.as_str() {
"Pending" => PreloadingStatus::Pending,
"Running" => PreloadingStatus::Running,
"Ready" => PreloadingStatus::Ready,
"Success" => PreloadingStatus::Success,
"Failure" => PreloadingStatus::Failure,
"NotSupported" => PreloadingStatus::NotSupported,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for PreloadingStatus {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for PreloadingStatus {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = PreloadingStatus;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"Pending" => PreloadingStatus::Pending,
"Running" => PreloadingStatus::Running,
"Ready" => PreloadingStatus::Ready,
"Success" => PreloadingStatus::Success,
"Failure" => PreloadingStatus::Failure,
"NotSupported" => PreloadingStatus::NotSupported,
_ => PreloadingStatus::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(PreloadingStatus::from(v))
}
}
d.deserialize_str(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
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,
Unknown(String),
}
impl PrerenderFinalStatus {
pub fn as_str(&self) -> &str {
match self {
Self::Activated => "Activated",
Self::Destroyed => "Destroyed",
Self::LowEndDevice => "LowEndDevice",
Self::InvalidSchemeRedirect => "InvalidSchemeRedirect",
Self::InvalidSchemeNavigation => "InvalidSchemeNavigation",
Self::NavigationRequestBlockedByCsp => "NavigationRequestBlockedByCsp",
Self::MojoBinderPolicy => "MojoBinderPolicy",
Self::RendererProcessCrashed => "RendererProcessCrashed",
Self::RendererProcessKilled => "RendererProcessKilled",
Self::Download => "Download",
Self::TriggerDestroyed => "TriggerDestroyed",
Self::NavigationNotCommitted => "NavigationNotCommitted",
Self::NavigationBadHttpStatus => "NavigationBadHttpStatus",
Self::ClientCertRequested => "ClientCertRequested",
Self::NavigationRequestNetworkError => "NavigationRequestNetworkError",
Self::CancelAllHostsForTesting => "CancelAllHostsForTesting",
Self::DidFailLoad => "DidFailLoad",
Self::Stop => "Stop",
Self::SslCertificateError => "SslCertificateError",
Self::LoginAuthRequested => "LoginAuthRequested",
Self::UaChangeRequiresReload => "UaChangeRequiresReload",
Self::BlockedByClient => "BlockedByClient",
Self::AudioOutputDeviceRequested => "AudioOutputDeviceRequested",
Self::MixedContent => "MixedContent",
Self::TriggerBackgrounded => "TriggerBackgrounded",
Self::MemoryLimitExceeded => "MemoryLimitExceeded",
Self::DataSaverEnabled => "DataSaverEnabled",
Self::TriggerUrlHasEffectiveUrl => "TriggerUrlHasEffectiveUrl",
Self::ActivatedBeforeStarted => "ActivatedBeforeStarted",
Self::InactivePageRestriction => "InactivePageRestriction",
Self::StartFailed => "StartFailed",
Self::TimeoutBackgrounded => "TimeoutBackgrounded",
Self::CrossSiteRedirectInInitialNavigation => "CrossSiteRedirectInInitialNavigation",
Self::CrossSiteNavigationInInitialNavigation => {
"CrossSiteNavigationInInitialNavigation"
}
Self::SameSiteCrossOriginRedirectNotOptInInInitialNavigation => {
"SameSiteCrossOriginRedirectNotOptInInInitialNavigation"
}
Self::SameSiteCrossOriginNavigationNotOptInInInitialNavigation => {
"SameSiteCrossOriginNavigationNotOptInInInitialNavigation"
}
Self::ActivationNavigationParameterMismatch => "ActivationNavigationParameterMismatch",
Self::ActivatedInBackground => "ActivatedInBackground",
Self::EmbedderHostDisallowed => "EmbedderHostDisallowed",
Self::ActivationNavigationDestroyedBeforeSuccess => {
"ActivationNavigationDestroyedBeforeSuccess"
}
Self::TabClosedByUserGesture => "TabClosedByUserGesture",
Self::TabClosedWithoutUserGesture => "TabClosedWithoutUserGesture",
Self::PrimaryMainFrameRendererProcessCrashed => {
"PrimaryMainFrameRendererProcessCrashed"
}
Self::PrimaryMainFrameRendererProcessKilled => "PrimaryMainFrameRendererProcessKilled",
Self::ActivationFramePolicyNotCompatible => "ActivationFramePolicyNotCompatible",
Self::PreloadingDisabled => "PreloadingDisabled",
Self::BatterySaverEnabled => "BatterySaverEnabled",
Self::ActivatedDuringMainFrameNavigation => "ActivatedDuringMainFrameNavigation",
Self::PreloadingUnsupportedByWebContents => "PreloadingUnsupportedByWebContents",
Self::CrossSiteRedirectInMainFrameNavigation => {
"CrossSiteRedirectInMainFrameNavigation"
}
Self::CrossSiteNavigationInMainFrameNavigation => {
"CrossSiteNavigationInMainFrameNavigation"
}
Self::SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation => {
"SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation"
}
Self::SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation => {
"SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation"
}
Self::MemoryPressureOnTrigger => "MemoryPressureOnTrigger",
Self::MemoryPressureAfterTriggered => "MemoryPressureAfterTriggered",
Self::PrerenderingDisabledByDevTools => "PrerenderingDisabledByDevTools",
Self::SpeculationRuleRemoved => "SpeculationRuleRemoved",
Self::ActivatedWithAuxiliaryBrowsingContexts => {
"ActivatedWithAuxiliaryBrowsingContexts"
}
Self::MaxNumOfRunningEagerPrerendersExceeded => {
"MaxNumOfRunningEagerPrerendersExceeded"
}
Self::MaxNumOfRunningNonEagerPrerendersExceeded => {
"MaxNumOfRunningNonEagerPrerendersExceeded"
}
Self::MaxNumOfRunningEmbedderPrerendersExceeded => {
"MaxNumOfRunningEmbedderPrerendersExceeded"
}
Self::PrerenderingUrlHasEffectiveUrl => "PrerenderingUrlHasEffectiveUrl",
Self::RedirectedPrerenderingUrlHasEffectiveUrl => {
"RedirectedPrerenderingUrlHasEffectiveUrl"
}
Self::ActivationUrlHasEffectiveUrl => "ActivationUrlHasEffectiveUrl",
Self::JavaScriptInterfaceAdded => "JavaScriptInterfaceAdded",
Self::JavaScriptInterfaceRemoved => "JavaScriptInterfaceRemoved",
Self::AllPrerenderingCanceled => "AllPrerenderingCanceled",
Self::WindowClosed => "WindowClosed",
Self::SlowNetwork => "SlowNetwork",
Self::OtherPrerenderedPageActivated => "OtherPrerenderedPageActivated",
Self::V8OptimizerDisabled => "V8OptimizerDisabled",
Self::PrerenderFailedDuringPrefetch => "PrerenderFailedDuringPrefetch",
Self::BrowsingDataRemoved => "BrowsingDataRemoved",
Self::PrerenderHostReused => "PrerenderHostReused",
Self::FormSubmitWhenPrerendering => "FormSubmitWhenPrerendering",
Self::CrossDocumentRestart => "CrossDocumentRestart",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for PrerenderFinalStatus {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for PrerenderFinalStatus {
fn from(value: String) -> Self {
match value.as_str() {
"Activated" => PrerenderFinalStatus::Activated,
"Destroyed" => PrerenderFinalStatus::Destroyed,
"LowEndDevice" => PrerenderFinalStatus::LowEndDevice,
"InvalidSchemeRedirect" => PrerenderFinalStatus::InvalidSchemeRedirect,
"InvalidSchemeNavigation" => PrerenderFinalStatus::InvalidSchemeNavigation,
"NavigationRequestBlockedByCsp" => PrerenderFinalStatus::NavigationRequestBlockedByCsp,
"MojoBinderPolicy" => PrerenderFinalStatus::MojoBinderPolicy,
"RendererProcessCrashed" => PrerenderFinalStatus::RendererProcessCrashed,
"RendererProcessKilled" => PrerenderFinalStatus::RendererProcessKilled,
"Download" => PrerenderFinalStatus::Download,
"TriggerDestroyed" => PrerenderFinalStatus::TriggerDestroyed,
"NavigationNotCommitted" => PrerenderFinalStatus::NavigationNotCommitted,
"NavigationBadHttpStatus" => PrerenderFinalStatus::NavigationBadHttpStatus,
"ClientCertRequested" => PrerenderFinalStatus::ClientCertRequested,
"NavigationRequestNetworkError" => PrerenderFinalStatus::NavigationRequestNetworkError,
"CancelAllHostsForTesting" => PrerenderFinalStatus::CancelAllHostsForTesting,
"DidFailLoad" => PrerenderFinalStatus::DidFailLoad,
"Stop" => PrerenderFinalStatus::Stop,
"SslCertificateError" => PrerenderFinalStatus::SslCertificateError,
"LoginAuthRequested" => PrerenderFinalStatus::LoginAuthRequested,
"UaChangeRequiresReload" => PrerenderFinalStatus::UaChangeRequiresReload,
"BlockedByClient" => PrerenderFinalStatus::BlockedByClient,
"AudioOutputDeviceRequested" => PrerenderFinalStatus::AudioOutputDeviceRequested,
"MixedContent" => PrerenderFinalStatus::MixedContent,
"TriggerBackgrounded" => PrerenderFinalStatus::TriggerBackgrounded,
"MemoryLimitExceeded" => PrerenderFinalStatus::MemoryLimitExceeded,
"DataSaverEnabled" => PrerenderFinalStatus::DataSaverEnabled,
"TriggerUrlHasEffectiveUrl" => PrerenderFinalStatus::TriggerUrlHasEffectiveUrl,
"ActivatedBeforeStarted" => PrerenderFinalStatus::ActivatedBeforeStarted,
"InactivePageRestriction" => PrerenderFinalStatus::InactivePageRestriction,
"StartFailed" => PrerenderFinalStatus::StartFailed,
"TimeoutBackgrounded" => PrerenderFinalStatus::TimeoutBackgrounded,
"CrossSiteRedirectInInitialNavigation" => {
PrerenderFinalStatus::CrossSiteRedirectInInitialNavigation
}
"CrossSiteNavigationInInitialNavigation" => {
PrerenderFinalStatus::CrossSiteNavigationInInitialNavigation
}
"SameSiteCrossOriginRedirectNotOptInInInitialNavigation" => {
PrerenderFinalStatus::SameSiteCrossOriginRedirectNotOptInInInitialNavigation
}
"SameSiteCrossOriginNavigationNotOptInInInitialNavigation" => {
PrerenderFinalStatus::SameSiteCrossOriginNavigationNotOptInInInitialNavigation
}
"ActivationNavigationParameterMismatch" => {
PrerenderFinalStatus::ActivationNavigationParameterMismatch
}
"ActivatedInBackground" => PrerenderFinalStatus::ActivatedInBackground,
"EmbedderHostDisallowed" => PrerenderFinalStatus::EmbedderHostDisallowed,
"ActivationNavigationDestroyedBeforeSuccess" => {
PrerenderFinalStatus::ActivationNavigationDestroyedBeforeSuccess
}
"TabClosedByUserGesture" => PrerenderFinalStatus::TabClosedByUserGesture,
"TabClosedWithoutUserGesture" => PrerenderFinalStatus::TabClosedWithoutUserGesture,
"PrimaryMainFrameRendererProcessCrashed" => {
PrerenderFinalStatus::PrimaryMainFrameRendererProcessCrashed
}
"PrimaryMainFrameRendererProcessKilled" => {
PrerenderFinalStatus::PrimaryMainFrameRendererProcessKilled
}
"ActivationFramePolicyNotCompatible" => {
PrerenderFinalStatus::ActivationFramePolicyNotCompatible
}
"PreloadingDisabled" => PrerenderFinalStatus::PreloadingDisabled,
"BatterySaverEnabled" => PrerenderFinalStatus::BatterySaverEnabled,
"ActivatedDuringMainFrameNavigation" => {
PrerenderFinalStatus::ActivatedDuringMainFrameNavigation
}
"PreloadingUnsupportedByWebContents" => {
PrerenderFinalStatus::PreloadingUnsupportedByWebContents
}
"CrossSiteRedirectInMainFrameNavigation" => {
PrerenderFinalStatus::CrossSiteRedirectInMainFrameNavigation
}
"CrossSiteNavigationInMainFrameNavigation" => {
PrerenderFinalStatus::CrossSiteNavigationInMainFrameNavigation
}
"SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation" => {
PrerenderFinalStatus::SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation
}
"SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation" => {
PrerenderFinalStatus::SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation
}
"MemoryPressureOnTrigger" => PrerenderFinalStatus::MemoryPressureOnTrigger,
"MemoryPressureAfterTriggered" => PrerenderFinalStatus::MemoryPressureAfterTriggered,
"PrerenderingDisabledByDevTools" => {
PrerenderFinalStatus::PrerenderingDisabledByDevTools
}
"SpeculationRuleRemoved" => PrerenderFinalStatus::SpeculationRuleRemoved,
"ActivatedWithAuxiliaryBrowsingContexts" => {
PrerenderFinalStatus::ActivatedWithAuxiliaryBrowsingContexts
}
"MaxNumOfRunningEagerPrerendersExceeded" => {
PrerenderFinalStatus::MaxNumOfRunningEagerPrerendersExceeded
}
"MaxNumOfRunningNonEagerPrerendersExceeded" => {
PrerenderFinalStatus::MaxNumOfRunningNonEagerPrerendersExceeded
}
"MaxNumOfRunningEmbedderPrerendersExceeded" => {
PrerenderFinalStatus::MaxNumOfRunningEmbedderPrerendersExceeded
}
"PrerenderingUrlHasEffectiveUrl" => {
PrerenderFinalStatus::PrerenderingUrlHasEffectiveUrl
}
"RedirectedPrerenderingUrlHasEffectiveUrl" => {
PrerenderFinalStatus::RedirectedPrerenderingUrlHasEffectiveUrl
}
"ActivationUrlHasEffectiveUrl" => PrerenderFinalStatus::ActivationUrlHasEffectiveUrl,
"JavaScriptInterfaceAdded" => PrerenderFinalStatus::JavaScriptInterfaceAdded,
"JavaScriptInterfaceRemoved" => PrerenderFinalStatus::JavaScriptInterfaceRemoved,
"AllPrerenderingCanceled" => PrerenderFinalStatus::AllPrerenderingCanceled,
"WindowClosed" => PrerenderFinalStatus::WindowClosed,
"SlowNetwork" => PrerenderFinalStatus::SlowNetwork,
"OtherPrerenderedPageActivated" => PrerenderFinalStatus::OtherPrerenderedPageActivated,
"V8OptimizerDisabled" => PrerenderFinalStatus::V8OptimizerDisabled,
"PrerenderFailedDuringPrefetch" => PrerenderFinalStatus::PrerenderFailedDuringPrefetch,
"BrowsingDataRemoved" => PrerenderFinalStatus::BrowsingDataRemoved,
"PrerenderHostReused" => PrerenderFinalStatus::PrerenderHostReused,
"FormSubmitWhenPrerendering" => PrerenderFinalStatus::FormSubmitWhenPrerendering,
"CrossDocumentRestart" => PrerenderFinalStatus::CrossDocumentRestart,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for PrerenderFinalStatus {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for PrerenderFinalStatus {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = PrerenderFinalStatus;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(
match v {
"Activated" => PrerenderFinalStatus::Activated,
"Destroyed" => PrerenderFinalStatus::Destroyed,
"LowEndDevice" => PrerenderFinalStatus::LowEndDevice,
"InvalidSchemeRedirect" => {
PrerenderFinalStatus::InvalidSchemeRedirect
}
"InvalidSchemeNavigation" => {
PrerenderFinalStatus::InvalidSchemeNavigation
}
"NavigationRequestBlockedByCsp" => {
PrerenderFinalStatus::NavigationRequestBlockedByCsp
}
"MojoBinderPolicy" => PrerenderFinalStatus::MojoBinderPolicy,
"RendererProcessCrashed" => {
PrerenderFinalStatus::RendererProcessCrashed
}
"RendererProcessKilled" => {
PrerenderFinalStatus::RendererProcessKilled
}
"Download" => PrerenderFinalStatus::Download,
"TriggerDestroyed" => PrerenderFinalStatus::TriggerDestroyed,
"NavigationNotCommitted" => {
PrerenderFinalStatus::NavigationNotCommitted
}
"NavigationBadHttpStatus" => {
PrerenderFinalStatus::NavigationBadHttpStatus
}
"ClientCertRequested" => {
PrerenderFinalStatus::ClientCertRequested
}
"NavigationRequestNetworkError" => {
PrerenderFinalStatus::NavigationRequestNetworkError
}
"CancelAllHostsForTesting" => {
PrerenderFinalStatus::CancelAllHostsForTesting
}
"DidFailLoad" => PrerenderFinalStatus::DidFailLoad,
"Stop" => PrerenderFinalStatus::Stop,
"SslCertificateError" => {
PrerenderFinalStatus::SslCertificateError
}
"LoginAuthRequested" => PrerenderFinalStatus::LoginAuthRequested,
"UaChangeRequiresReload" => {
PrerenderFinalStatus::UaChangeRequiresReload
}
"BlockedByClient" => PrerenderFinalStatus::BlockedByClient,
"AudioOutputDeviceRequested" => {
PrerenderFinalStatus::AudioOutputDeviceRequested
}
"MixedContent" => PrerenderFinalStatus::MixedContent,
"TriggerBackgrounded" => {
PrerenderFinalStatus::TriggerBackgrounded
}
"MemoryLimitExceeded" => {
PrerenderFinalStatus::MemoryLimitExceeded
}
"DataSaverEnabled" => PrerenderFinalStatus::DataSaverEnabled,
"TriggerUrlHasEffectiveUrl" => {
PrerenderFinalStatus::TriggerUrlHasEffectiveUrl
}
"ActivatedBeforeStarted" => {
PrerenderFinalStatus::ActivatedBeforeStarted
}
"InactivePageRestriction" => {
PrerenderFinalStatus::InactivePageRestriction
}
"StartFailed" => PrerenderFinalStatus::StartFailed,
"TimeoutBackgrounded" => {
PrerenderFinalStatus::TimeoutBackgrounded
}
"CrossSiteRedirectInInitialNavigation" => {
PrerenderFinalStatus::CrossSiteRedirectInInitialNavigation
}
"CrossSiteNavigationInInitialNavigation" => {
PrerenderFinalStatus::CrossSiteNavigationInInitialNavigation
}
"SameSiteCrossOriginRedirectNotOptInInInitialNavigation" => {
PrerenderFinalStatus::SameSiteCrossOriginRedirectNotOptInInInitialNavigation
}
"SameSiteCrossOriginNavigationNotOptInInInitialNavigation" => {
PrerenderFinalStatus::SameSiteCrossOriginNavigationNotOptInInInitialNavigation
}
"ActivationNavigationParameterMismatch" => {
PrerenderFinalStatus::ActivationNavigationParameterMismatch
}
"ActivatedInBackground" => {
PrerenderFinalStatus::ActivatedInBackground
}
"EmbedderHostDisallowed" => {
PrerenderFinalStatus::EmbedderHostDisallowed
}
"ActivationNavigationDestroyedBeforeSuccess" => {
PrerenderFinalStatus::ActivationNavigationDestroyedBeforeSuccess
}
"TabClosedByUserGesture" => {
PrerenderFinalStatus::TabClosedByUserGesture
}
"TabClosedWithoutUserGesture" => {
PrerenderFinalStatus::TabClosedWithoutUserGesture
}
"PrimaryMainFrameRendererProcessCrashed" => {
PrerenderFinalStatus::PrimaryMainFrameRendererProcessCrashed
}
"PrimaryMainFrameRendererProcessKilled" => {
PrerenderFinalStatus::PrimaryMainFrameRendererProcessKilled
}
"ActivationFramePolicyNotCompatible" => {
PrerenderFinalStatus::ActivationFramePolicyNotCompatible
}
"PreloadingDisabled" => PrerenderFinalStatus::PreloadingDisabled,
"BatterySaverEnabled" => {
PrerenderFinalStatus::BatterySaverEnabled
}
"ActivatedDuringMainFrameNavigation" => {
PrerenderFinalStatus::ActivatedDuringMainFrameNavigation
}
"PreloadingUnsupportedByWebContents" => {
PrerenderFinalStatus::PreloadingUnsupportedByWebContents
}
"CrossSiteRedirectInMainFrameNavigation" => {
PrerenderFinalStatus::CrossSiteRedirectInMainFrameNavigation
}
"CrossSiteNavigationInMainFrameNavigation" => {
PrerenderFinalStatus::CrossSiteNavigationInMainFrameNavigation
}
"SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation" => {
PrerenderFinalStatus::SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation
}
"SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation" => {
PrerenderFinalStatus::SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation
}
"MemoryPressureOnTrigger" => {
PrerenderFinalStatus::MemoryPressureOnTrigger
}
"MemoryPressureAfterTriggered" => {
PrerenderFinalStatus::MemoryPressureAfterTriggered
}
"PrerenderingDisabledByDevTools" => {
PrerenderFinalStatus::PrerenderingDisabledByDevTools
}
"SpeculationRuleRemoved" => {
PrerenderFinalStatus::SpeculationRuleRemoved
}
"ActivatedWithAuxiliaryBrowsingContexts" => {
PrerenderFinalStatus::ActivatedWithAuxiliaryBrowsingContexts
}
"MaxNumOfRunningEagerPrerendersExceeded" => {
PrerenderFinalStatus::MaxNumOfRunningEagerPrerendersExceeded
}
"MaxNumOfRunningNonEagerPrerendersExceeded" => {
PrerenderFinalStatus::MaxNumOfRunningNonEagerPrerendersExceeded
}
"MaxNumOfRunningEmbedderPrerendersExceeded" => {
PrerenderFinalStatus::MaxNumOfRunningEmbedderPrerendersExceeded
}
"PrerenderingUrlHasEffectiveUrl" => {
PrerenderFinalStatus::PrerenderingUrlHasEffectiveUrl
}
"RedirectedPrerenderingUrlHasEffectiveUrl" => {
PrerenderFinalStatus::RedirectedPrerenderingUrlHasEffectiveUrl
}
"ActivationUrlHasEffectiveUrl" => {
PrerenderFinalStatus::ActivationUrlHasEffectiveUrl
}
"JavaScriptInterfaceAdded" => {
PrerenderFinalStatus::JavaScriptInterfaceAdded
}
"JavaScriptInterfaceRemoved" => {
PrerenderFinalStatus::JavaScriptInterfaceRemoved
}
"AllPrerenderingCanceled" => {
PrerenderFinalStatus::AllPrerenderingCanceled
}
"WindowClosed" => PrerenderFinalStatus::WindowClosed,
"SlowNetwork" => PrerenderFinalStatus::SlowNetwork,
"OtherPrerenderedPageActivated" => {
PrerenderFinalStatus::OtherPrerenderedPageActivated
}
"V8OptimizerDisabled" => {
PrerenderFinalStatus::V8OptimizerDisabled
}
"PrerenderFailedDuringPrefetch" => {
PrerenderFinalStatus::PrerenderFailedDuringPrefetch
}
"BrowsingDataRemoved" => {
PrerenderFinalStatus::BrowsingDataRemoved
}
"PrerenderHostReused" => {
PrerenderFinalStatus::PrerenderHostReused
}
"FormSubmitWhenPrerendering" => {
PrerenderFinalStatus::FormSubmitWhenPrerendering
}
"CrossDocumentRestart" => {
PrerenderFinalStatus::CrossDocumentRestart
}
_ => PrerenderFinalStatus::Unknown(v.to_owned()),
},
)
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(PrerenderFinalStatus::from(v))
}
}
d.deserialize_str(Visitor)
}
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct PrerenderMismatchedHeaders {
#[serde(rename = "headerName")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub header_name: String,
#[serde(rename = "initialValue")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub initial_value: Option<String>,
#[serde(rename = "activationValue")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub activation_value: Option<String>,
}
impl<'de> serde::Deserialize<'de> for PrerenderMismatchedHeaders {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = PrerenderMismatchedHeaders;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议 object")
}
fn visit_map<A: serde::de::MapAccess<'de>>(
self,
a: A,
) -> Result<Self::Value, A::Error> {
#[derive(serde::Deserialize)]
struct Fields {
#[serde(rename = "headerName")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub header_name: String,
#[serde(rename = "initialValue")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub initial_value: Option<String>,
#[serde(rename = "activationValue")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub activation_value: Option<String>,
}
let fields = <Fields as serde::Deserialize>::deserialize(
serde::de::value::MapAccessDeserializer::new(a),
)?;
Ok(PrerenderMismatchedHeaders {
header_name: fields.header_name,
initial_value: fields.initial_value,
activation_value: fields.activation_value,
})
}
}
d.deserialize_map(Visitor)
}
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct RuleSet {
#[serde(rename = "id")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub id: crate::preload::types::RuleSetId,
#[serde(rename = "loaderId")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub loader_id: crate::network::types::LoaderId,
#[serde(rename = "sourceText")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub source_text: String,
#[serde(rename = "backendNodeId")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub backend_node_id: Option<crate::dom::types::BackendNodeId>,
#[serde(rename = "url")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub url: Option<String>,
#[serde(rename = "requestId")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub request_id: Option<crate::network::types::RequestId>,
#[serde(rename = "errorType")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub error_type: Option<crate::preload::types::RuleSetErrorType>,
#[serde(rename = "errorMessage")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub error_message: Option<String>,
#[serde(rename = "tag")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub tag: Option<String>,
}
impl<'de> serde::Deserialize<'de> for RuleSet {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = RuleSet;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议 object")
}
fn visit_map<A: serde::de::MapAccess<'de>>(
self,
a: A,
) -> Result<Self::Value, A::Error> {
#[derive(serde::Deserialize)]
struct Fields {
#[serde(rename = "id")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub id: crate::preload::types::RuleSetId,
#[serde(rename = "loaderId")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub loader_id: crate::network::types::LoaderId,
#[serde(rename = "sourceText")]
#[serde(deserialize_with = "ydp_core::binding_support::required")]
pub source_text: String,
#[serde(rename = "backendNodeId")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub backend_node_id: Option<crate::dom::types::BackendNodeId>,
#[serde(rename = "url")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub url: Option<String>,
#[serde(rename = "requestId")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub request_id: Option<crate::network::types::RequestId>,
#[serde(rename = "errorType")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub error_type: Option<crate::preload::types::RuleSetErrorType>,
#[serde(rename = "errorMessage")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub error_message: Option<String>,
#[serde(rename = "tag")]
#[serde(
default,
deserialize_with = "ydp_core::binding_support::presence",
skip_serializing_if = "Option::is_none"
)]
pub tag: Option<String>,
}
let fields = <Fields as serde::Deserialize>::deserialize(
serde::de::value::MapAccessDeserializer::new(a),
)?;
Ok(RuleSet {
id: fields.id,
loader_id: fields.loader_id,
source_text: fields.source_text,
backend_node_id: fields.backend_node_id,
url: fields.url,
request_id: fields.request_id,
error_type: fields.error_type,
error_message: fields.error_message,
tag: fields.tag,
})
}
}
d.deserialize_map(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum RuleSetErrorType {
SourceIsNotJsonObject,
InvalidRulesSkipped,
InvalidRulesetLevelTag,
Unknown(String),
}
impl RuleSetErrorType {
pub fn as_str(&self) -> &str {
match self {
Self::SourceIsNotJsonObject => "SourceIsNotJsonObject",
Self::InvalidRulesSkipped => "InvalidRulesSkipped",
Self::InvalidRulesetLevelTag => "InvalidRulesetLevelTag",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for RuleSetErrorType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for RuleSetErrorType {
fn from(value: String) -> Self {
match value.as_str() {
"SourceIsNotJsonObject" => RuleSetErrorType::SourceIsNotJsonObject,
"InvalidRulesSkipped" => RuleSetErrorType::InvalidRulesSkipped,
"InvalidRulesetLevelTag" => RuleSetErrorType::InvalidRulesetLevelTag,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for RuleSetErrorType {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for RuleSetErrorType {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = RuleSetErrorType;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"SourceIsNotJsonObject" => RuleSetErrorType::SourceIsNotJsonObject,
"InvalidRulesSkipped" => RuleSetErrorType::InvalidRulesSkipped,
"InvalidRulesetLevelTag" => RuleSetErrorType::InvalidRulesetLevelTag,
_ => RuleSetErrorType::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(RuleSetErrorType::from(v))
}
}
d.deserialize_str(Visitor)
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(transparent)]
pub struct RuleSetId(String);
impl RuleSetId {
pub fn new(value: String) -> Self {
Self(value)
}
pub fn into_inner(self) -> String {
self.0
}
pub fn as_str(&self) -> &str {
&self.0
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum SpeculationAction {
Prefetch,
Prerender,
PrerenderUntilScript,
Unknown(String),
}
impl SpeculationAction {
pub fn as_str(&self) -> &str {
match self {
Self::Prefetch => "Prefetch",
Self::Prerender => "Prerender",
Self::PrerenderUntilScript => "PrerenderUntilScript",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for SpeculationAction {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for SpeculationAction {
fn from(value: String) -> Self {
match value.as_str() {
"Prefetch" => SpeculationAction::Prefetch,
"Prerender" => SpeculationAction::Prerender,
"PrerenderUntilScript" => SpeculationAction::PrerenderUntilScript,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for SpeculationAction {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for SpeculationAction {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = SpeculationAction;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"Prefetch" => SpeculationAction::Prefetch,
"Prerender" => SpeculationAction::Prerender,
"PrerenderUntilScript" => SpeculationAction::PrerenderUntilScript,
_ => SpeculationAction::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(SpeculationAction::from(v))
}
}
d.deserialize_str(Visitor)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum SpeculationTargetHint {
Blank,
Self_,
Unknown(String),
}
impl SpeculationTargetHint {
pub fn as_str(&self) -> &str {
match self {
Self::Blank => "Blank",
Self::Self_ => "Self",
Self::Unknown(value) => value,
}
}
}
impl AsRef<str> for SpeculationTargetHint {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl From<String> for SpeculationTargetHint {
fn from(value: String) -> Self {
match value.as_str() {
"Blank" => SpeculationTargetHint::Blank,
"Self" => SpeculationTargetHint::Self_,
_ => Self::Unknown(value),
}
}
}
impl serde::Serialize for SpeculationTargetHint {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
s.serialize_str(self.as_str())
}
}
impl<'de> serde::Deserialize<'de> for SpeculationTargetHint {
fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
struct Visitor;
impl<'de> serde::de::Visitor<'de> for Visitor {
type Value = SpeculationTargetHint;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("协议字符串枚举")
}
fn visit_str<E: serde::de::Error>(self, v: &str) -> Result<Self::Value, E> {
Ok(match v {
"Blank" => SpeculationTargetHint::Blank,
"Self" => SpeculationTargetHint::Self_,
_ => SpeculationTargetHint::Unknown(v.to_owned()),
})
}
fn visit_string<E: serde::de::Error>(self, v: String) -> Result<Self::Value, E> {
Ok(SpeculationTargetHint::from(v))
}
}
d.deserialize_str(Visitor)
}
}