browser_commander/playwright/protocol/
root.rs1#![allow(clippy::all, missing_docs, unused_imports)]
5
6use serde::{Deserialize, Serialize};
7
8use super::*;
9use crate::playwright::connection::{
10 Binary, Channel, ChannelType, ObjectRef, ProtocolError, ProtocolEvent, Ref,
11};
12
13#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
15pub struct RootInitializer {}
16
17#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
19pub struct RootInitializeParams {
20 #[serde(rename = "sdkLanguage")]
21 pub sdk_language: SDKLanguage,
22}
23
24#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
26pub struct RootInitializeResult {
27 #[serde(rename = "playwright")]
28 pub playwright: Ref<Playwright>,
29}
30
31#[derive(Debug, Clone, PartialEq)]
33pub enum RootEvent {
34 Unknown {
36 method: String,
38 params: serde_json::Value,
40 },
41}
42
43impl ProtocolEvent for RootEvent {
44 fn parse(method: &str, params: serde_json::Value) -> Result<Self, serde_json::Error> {
45 match method {
46 _ => Ok(Self::Unknown { method: method.to_string(), params }),
47 }
48 }
49}
50
51#[derive(Debug, Clone)]
53pub struct Root {
54 channel: Channel,
55}
56
57impl ChannelType for Root {
58 const INTERFACE: &'static str = "Root";
59 type Initializer = RootInitializer;
60 type Event = RootEvent;
61
62 fn accepts(interface: &str) -> bool {
63 matches!(interface, "Root")
64 }
65
66 fn from_channel(channel: Channel) -> Self {
67 Self { channel }
68 }
69
70 fn channel(&self) -> &Channel {
71 &self.channel
72 }
73}
74
75impl Root {
76 pub async fn initialize(&self, params: RootInitializeParams) -> Result<RootInitializeResult, ProtocolError> {
78 self.channel.send("initialize", ¶ms).await
79 }
80}