1use std::fmt;
2
3use crate::cdp::browser_protocol::fetch;
4use crate::cdp::browser_protocol::network::{self, CookieParam, DeleteCookiesParams};
5use crate::cdp::js_protocol::runtime::{
6 CallFunctionOnParams, EvaluateParams, ExceptionDetails, StackTrace,
7};
8use crate::revision::Revision;
9
10#[allow(clippy::multiple_bound_locations)]
11#[allow(clippy::derive_partial_eq_without_eq)]
12#[allow(unreachable_patterns)]
13pub mod cdp;
14pub mod revision;
15
16pub const CURRENT_REVISION: Revision = Revision(1581282);
32
33impl From<fetch::RequestId> for network::RequestId {
40 fn from(req: fetch::RequestId) -> Self {
41 let s: String = req.into();
42 s.into()
43 }
44}
45
46impl From<network::RequestId> for fetch::RequestId {
47 fn from(req: network::RequestId) -> Self {
48 let s: String = req.into();
49 s.into()
50 }
51}
52
53impl From<network::InterceptionId> for fetch::RequestId {
54 fn from(req: network::InterceptionId) -> Self {
55 let s: String = req.into();
56 s.into()
57 }
58}
59
60impl From<network::InterceptionId> for network::RequestId {
61 fn from(req: network::InterceptionId) -> Self {
62 let s: String = req.into();
63 s.into()
64 }
65}
66
67impl From<fetch::RequestId> for network::InterceptionId {
68 fn from(req: fetch::RequestId) -> Self {
69 let s: String = req.into();
70 s.into()
71 }
72}
73
74impl From<network::RequestId> for network::InterceptionId {
75 fn from(req: network::RequestId) -> Self {
76 let s: String = req.into();
77 s.into()
78 }
79}
80
81impl DeleteCookiesParams {
82 pub fn from_cookie(param: &CookieParam) -> Self {
84 DeleteCookiesParams {
85 name: param.name.clone(),
86 url: param.url.clone(),
87 domain: param.domain.clone(),
88 path: param.path.clone(),
89 partition_key: param.partition_key.clone(),
90 }
91 }
92}
93
94impl From<EvaluateParams> for CallFunctionOnParams {
95 fn from(params: EvaluateParams) -> CallFunctionOnParams {
96 CallFunctionOnParams {
97 function_declaration: params.expression,
98 object_id: None,
99 arguments: None,
100 silent: params.silent,
101 return_by_value: params.return_by_value,
102 generate_preview: params.generate_preview,
103 user_gesture: params.user_gesture,
104 await_promise: params.await_promise,
105 execution_context_id: params.context_id,
106 object_group: params.object_group,
107 throw_on_side_effect: None,
108 unique_context_id: None,
109 serialization_options: None,
110 }
111 }
112}
113
114impl fmt::Display for ExceptionDetails {
115 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
116 writeln!(
117 f,
118 "{}:{}: {}",
119 self.line_number, self.column_number, self.text
120 )?;
121
122 if let Some(stack) = self.stack_trace.as_ref() {
123 stack.fmt(f)?
124 }
125 Ok(())
126 }
127}
128
129impl std::error::Error for ExceptionDetails {}
130
131impl fmt::Display for StackTrace {
132 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
133 if let Some(desc) = self.description.as_ref() {
134 writeln!(f, "{desc}")?;
135 }
136 for frame in &self.call_frames {
137 writeln!(
138 f,
139 "{}@{}:{}:{}",
140 frame.function_name, frame.url, frame.line_number, frame.column_number
141 )?;
142 }
143 Ok(())
144 }
145}