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 ConsoleMessage<'a> {
source: Cow<'a, str>,
level: Cow<'a, str>,
text: Cow<'a, str>,
#[serde(skip_serializing_if = "Option::is_none")]
url: Option<Cow<'a, str>>,
#[serde(skip_serializing_if = "Option::is_none")]
line: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
column: Option<i64>,
}
impl<'a> ConsoleMessage<'a> {
pub fn builder(source: impl Into<Cow<'a, str>>, level: impl Into<Cow<'a, str>>, text: impl Into<Cow<'a, str>>) -> ConsoleMessageBuilder<'a> {
ConsoleMessageBuilder {
source: source.into(),
level: level.into(),
text: text.into(),
url: None,
line: None,
column: 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 url(&self) -> Option<&str> { self.url.as_deref() }
pub fn line(&self) -> Option<i64> { self.line }
pub fn column(&self) -> Option<i64> { self.column }
}
pub struct ConsoleMessageBuilder<'a> {
source: Cow<'a, str>,
level: Cow<'a, str>,
text: Cow<'a, str>,
url: Option<Cow<'a, str>>,
line: Option<i64>,
column: Option<i64>,
}
impl<'a> ConsoleMessageBuilder<'a> {
pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
pub fn line(mut self, line: i64) -> Self { self.line = Some(line); self }
pub fn column(mut self, column: i64) -> Self { self.column = Some(column); self }
pub fn build(self) -> ConsoleMessage<'a> {
ConsoleMessage {
source: self.source,
level: self.level,
text: self.text,
url: self.url,
line: self.line,
column: self.column,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct ClearMessagesParams {}
impl ClearMessagesParams { pub const METHOD: &'static str = "Console.clearMessages"; }
impl<'a> crate::CdpCommand<'a> for ClearMessagesParams {
const METHOD: &'static str = "Console.clearMessages";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DisableParams {}
impl DisableParams { pub const METHOD: &'static str = "Console.disable"; }
impl<'a> crate::CdpCommand<'a> for DisableParams {
const METHOD: &'static str = "Console.disable";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct EnableParams {}
impl EnableParams { pub const METHOD: &'static str = "Console.enable"; }
impl<'a> crate::CdpCommand<'a> for EnableParams {
const METHOD: &'static str = "Console.enable";
type Response = crate::EmptyReturns;
}