js_protocol/console/
mod.rs1use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11#[serde(rename_all = "camelCase")]
12pub struct ConsoleMessage<'a> {
13 source: Cow<'a, str>,
15 level: Cow<'a, str>,
17 text: Cow<'a, str>,
19 #[serde(skip_serializing_if = "Option::is_none")]
21 url: Option<Cow<'a, str>>,
22 #[serde(skip_serializing_if = "Option::is_none")]
24 line: Option<i64>,
25 #[serde(skip_serializing_if = "Option::is_none")]
27 column: Option<i64>,
28}
29
30impl<'a> ConsoleMessage<'a> {
31 pub fn builder(source: impl Into<Cow<'a, str>>, level: impl Into<Cow<'a, str>>, text: impl Into<Cow<'a, str>>) -> ConsoleMessageBuilder<'a> {
36 ConsoleMessageBuilder {
37 source: source.into(),
38 level: level.into(),
39 text: text.into(),
40 url: None,
41 line: None,
42 column: None,
43 }
44 }
45 pub fn source(&self) -> &str { self.source.as_ref() }
47 pub fn level(&self) -> &str { self.level.as_ref() }
49 pub fn text(&self) -> &str { self.text.as_ref() }
51 pub fn url(&self) -> Option<&str> { self.url.as_deref() }
53 pub fn line(&self) -> Option<i64> { self.line }
55 pub fn column(&self) -> Option<i64> { self.column }
57}
58
59
60pub struct ConsoleMessageBuilder<'a> {
61 source: Cow<'a, str>,
62 level: Cow<'a, str>,
63 text: Cow<'a, str>,
64 url: Option<Cow<'a, str>>,
65 line: Option<i64>,
66 column: Option<i64>,
67}
68
69impl<'a> ConsoleMessageBuilder<'a> {
70 pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
72 pub fn line(mut self, line: i64) -> Self { self.line = Some(line); self }
74 pub fn column(mut self, column: i64) -> Self { self.column = Some(column); self }
76 pub fn build(self) -> ConsoleMessage<'a> {
77 ConsoleMessage {
78 source: self.source,
79 level: self.level,
80 text: self.text,
81 url: self.url,
82 line: self.line,
83 column: self.column,
84 }
85 }
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize, Default)]
89pub struct ClearMessagesParams {}
90
91impl ClearMessagesParams { pub const METHOD: &'static str = "Console.clearMessages"; }
92
93impl<'a> crate::CdpCommand<'a> for ClearMessagesParams {
94 const METHOD: &'static str = "Console.clearMessages";
95 type Response = crate::EmptyReturns;
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize, Default)]
99pub struct DisableParams {}
100
101impl DisableParams { pub const METHOD: &'static str = "Console.disable"; }
102
103impl<'a> crate::CdpCommand<'a> for DisableParams {
104 const METHOD: &'static str = "Console.disable";
105 type Response = crate::EmptyReturns;
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize, Default)]
109pub struct EnableParams {}
110
111impl EnableParams { pub const METHOD: &'static str = "Console.enable"; }
112
113impl<'a> crate::CdpCommand<'a> for EnableParams {
114 const METHOD: &'static str = "Console.enable";
115 type Response = crate::EmptyReturns;
116}