chrome_devtools/domain/runtime/event/
console_api_called.rs

1use std::fmt;
2
3use serde::{Deserialize, Serialize};
4
5use crate::domain::runtime::r#type::RemoteObject;
6
7/// Issued when console API was called.
8/// See [Runtime.consoleAPICalled](https://chromedevtools.github.io/devtools-protocol/tot/Runtime#event-bindingCalled)
9#[derive(Debug, Serialize, Deserialize, Clone)]
10pub struct Event {
11    /// Type of the call
12    pub r#type: String, // TODO: make this an enum
13    /// Call arguments
14    pub args: Vec<RemoteObject>,
15    // TODO: Add other parameters
16}
17
18impl fmt::Display for Event {
19    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
20        let last_index = self.args.len() - 1;
21        for (index, arg) in self.args.iter().enumerate() {
22            write!(f, "{}", arg)?;
23            if index < last_index {
24                write!(f, " ")?;
25            }
26        }
27        Ok(())
28    }
29}