#![allow(clippy::all, missing_docs, unused_imports)]
use serde::{Deserialize, Serialize};
use super::*;
use crate::playwright::connection::{
Binary, Channel, ChannelType, ObjectRef, ProtocolError, ProtocolEvent, Ref,
};
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RootInitializer {}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RootInitializeParams {
#[serde(rename = "sdkLanguage")]
pub sdk_language: SDKLanguage,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct RootInitializeResult {
#[serde(rename = "playwright")]
pub playwright: Ref<Playwright>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum RootEvent {
Unknown {
method: String,
params: serde_json::Value,
},
}
impl ProtocolEvent for RootEvent {
fn parse(method: &str, params: serde_json::Value) -> Result<Self, serde_json::Error> {
match method {
_ => Ok(Self::Unknown { method: method.to_string(), params }),
}
}
}
#[derive(Debug, Clone)]
pub struct Root {
channel: Channel,
}
impl ChannelType for Root {
const INTERFACE: &'static str = "Root";
type Initializer = RootInitializer;
type Event = RootEvent;
fn accepts(interface: &str) -> bool {
matches!(interface, "Root")
}
fn from_channel(channel: Channel) -> Self {
Self { channel }
}
fn channel(&self) -> &Channel {
&self.channel
}
}
impl Root {
pub async fn initialize(&self, params: RootInitializeParams) -> Result<RootInitializeResult, ProtocolError> {
self.channel.send("initialize", ¶ms).await
}
}