#![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 BindingCallInitializer {
#[serde(rename = "frame")]
pub frame: Ref<Frame>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "args")]
pub args: Vec<SerializedValue>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct BindingCallRejectParams {
#[serde(rename = "error")]
pub error: SerializedError,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct BindingCallResolveParams {
#[serde(rename = "result")]
pub result: SerializedArgument,
}
#[derive(Debug, Clone, PartialEq)]
pub enum BindingCallEvent {
Unknown {
method: String,
params: serde_json::Value,
},
}
impl ProtocolEvent for BindingCallEvent {
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 BindingCall {
channel: Channel,
}
impl ChannelType for BindingCall {
const INTERFACE: &'static str = "BindingCall";
type Initializer = BindingCallInitializer;
type Event = BindingCallEvent;
fn accepts(interface: &str) -> bool {
matches!(interface, "BindingCall")
}
fn from_channel(channel: Channel) -> Self {
Self { channel }
}
fn channel(&self) -> &Channel {
&self.channel
}
}
impl BindingCall {
pub async fn reject(&self, params: BindingCallRejectParams) -> Result<(), ProtocolError> {
self.channel.send_no_result("reject", ¶ms).await
}
pub async fn resolve(&self, params: BindingCallResolveParams) -> Result<(), ProtocolError> {
self.channel.send_no_result("resolve", ¶ms).await
}
}