use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
use std::borrow::Cow;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct LogEntry<'a> {
source: Cow<'a, str>,
level: Cow<'a, str>,
text: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
category: Option<Cow<'a, str>>,
timestamp: crate::runtime::Timestamp,
#[serde(skip_serializing_if = "Option::is_none")]
url: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none", rename = "lineNumber")]
line_number: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none", rename = "stackTrace")]
stack_trace: Option<crate::runtime::StackTrace>,
#[serde(skip_serializing_if = "Option::is_none", rename = "networkRequestId")]
network_request_id: Option<crate::network::RequestId<'a>>,
#[serde(skip_serializing_if = "Option::is_none", rename = "workerId")]
worker_id: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
args: Option<Vec<crate::runtime::RemoteObject>>,
}
impl<'a> LogEntry<'a> {
pub fn builder(source: impl Into<Cow<'a, str>>, level: impl Into<Cow<'a, str>>, text: impl Into<Cow<'a, str>>, timestamp: crate::runtime::Timestamp) -> LogEntryBuilder<'a> {
LogEntryBuilder {
source: source.into(),
level: level.into(),
text: text.into(),
category: None,
timestamp: timestamp,
url: None,
line_number: None,
stack_trace: None,
network_request_id: None,
worker_id: None,
args: None,
}
}
pub fn source(&self) -> &str { self.source.as_ref() }
pub fn level(&self) -> &str { self.level.as_ref() }
pub fn text(&self) -> &str { self.text.as_ref() }
pub fn category(&self) -> Option<&str> { self.category.as_deref() }
pub fn timestamp(&self) -> &crate::runtime::Timestamp { &self.timestamp }
pub fn url(&self) -> Option<&str> { self.url.as_deref() }
pub fn line_number(&self) -> Option<i64> { self.line_number }
pub fn stack_trace(&self) -> Option<&crate::runtime::StackTrace> { self.stack_trace.as_ref() }
pub fn network_request_id(&self) -> Option<&crate::network::RequestId<'a>> { self.network_request_id.as_ref() }
pub fn worker_id(&self) -> Option<&str> { self.worker_id.as_deref() }
pub fn args(&self) -> Option<&[crate::runtime::RemoteObject]> { self.args.as_deref() }
}
pub struct LogEntryBuilder<'a> {
source: Cow<'a, str>,
level: Cow<'a, str>,
text: Cow<'a, str>,
category: Option<Cow<'a, str>>,
timestamp: crate::runtime::Timestamp,
url: Option<Cow<'a, str>>,
line_number: Option<i64>,
stack_trace: Option<crate::runtime::StackTrace>,
network_request_id: Option<crate::network::RequestId<'a>>,
worker_id: Option<Cow<'a, str>>,
args: Option<Vec<crate::runtime::RemoteObject>>,
}
impl<'a> LogEntryBuilder<'a> {
pub fn category(mut self, category: impl Into<Cow<'a, str>>) -> Self { self.category = Some(category.into()); self }
pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
pub fn line_number(mut self, line_number: i64) -> Self { self.line_number = Some(line_number); self }
pub fn stack_trace(mut self, stack_trace: crate::runtime::StackTrace) -> Self { self.stack_trace = Some(stack_trace); self }
pub fn network_request_id(mut self, network_request_id: crate::network::RequestId<'a>) -> Self { self.network_request_id = Some(network_request_id); self }
pub fn worker_id(mut self, worker_id: impl Into<Cow<'a, str>>) -> Self { self.worker_id = Some(worker_id.into()); self }
pub fn args(mut self, args: Vec<crate::runtime::RemoteObject>) -> Self { self.args = Some(args); self }
pub fn build(self) -> LogEntry<'a> {
LogEntry {
source: self.source,
level: self.level,
text: self.text,
category: self.category,
timestamp: self.timestamp,
url: self.url,
line_number: self.line_number,
stack_trace: self.stack_trace,
network_request_id: self.network_request_id,
worker_id: self.worker_id,
args: self.args,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ViolationSetting<'a> {
name: Cow<'a, str>,
threshold: f64,
}
impl<'a> ViolationSetting<'a> {
pub fn builder(name: impl Into<Cow<'a, str>>, threshold: f64) -> ViolationSettingBuilder<'a> {
ViolationSettingBuilder {
name: name.into(),
threshold: threshold,
}
}
pub fn name(&self) -> &str { self.name.as_ref() }
pub fn threshold(&self) -> f64 { self.threshold }
}
pub struct ViolationSettingBuilder<'a> {
name: Cow<'a, str>,
threshold: f64,
}
impl<'a> ViolationSettingBuilder<'a> {
pub fn build(self) -> ViolationSetting<'a> {
ViolationSetting {
name: self.name,
threshold: self.threshold,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ClearParams {}
impl ClearParams { pub const METHOD: &'static str = "Log.clear"; }
impl<'a> crate::CdpCommand<'a> for ClearParams {
const METHOD: &'static str = "Log.clear";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DisableParams {}
impl DisableParams { pub const METHOD: &'static str = "Log.disable"; }
impl<'a> crate::CdpCommand<'a> for DisableParams {
const METHOD: &'static str = "Log.disable";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EnableParams {}
impl EnableParams { pub const METHOD: &'static str = "Log.enable"; }
impl<'a> crate::CdpCommand<'a> for EnableParams {
const METHOD: &'static str = "Log.enable";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct StartViolationsReportParams<'a> {
config: Vec<ViolationSetting<'a>>,
}
impl<'a> StartViolationsReportParams<'a> {
pub fn builder(config: Vec<ViolationSetting<'a>>) -> StartViolationsReportParamsBuilder<'a> {
StartViolationsReportParamsBuilder {
config: config,
}
}
pub fn config(&self) -> &[ViolationSetting<'a>] { &self.config }
}
pub struct StartViolationsReportParamsBuilder<'a> {
config: Vec<ViolationSetting<'a>>,
}
impl<'a> StartViolationsReportParamsBuilder<'a> {
pub fn build(self) -> StartViolationsReportParams<'a> {
StartViolationsReportParams {
config: self.config,
}
}
}
impl<'a> StartViolationsReportParams<'a> { pub const METHOD: &'static str = "Log.startViolationsReport"; }
impl<'a> crate::CdpCommand<'a> for StartViolationsReportParams<'a> {
const METHOD: &'static str = "Log.startViolationsReport";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct StopViolationsReportParams {}
impl StopViolationsReportParams { pub const METHOD: &'static str = "Log.stopViolationsReport"; }
impl<'a> crate::CdpCommand<'a> for StopViolationsReportParams {
const METHOD: &'static str = "Log.stopViolationsReport";
type Response = crate::EmptyReturns;
}