#![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 DisposableInitializer {}
#[derive(Debug, Clone, PartialEq)]
pub enum DisposableEvent {
Unknown {
method: String,
params: serde_json::Value,
},
}
impl ProtocolEvent for DisposableEvent {
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 Disposable {
channel: Channel,
}
impl ChannelType for Disposable {
const INTERFACE: &'static str = "Disposable";
type Initializer = DisposableInitializer;
type Event = DisposableEvent;
fn accepts(interface: &str) -> bool {
matches!(interface, "Disposable")
}
fn from_channel(channel: Channel) -> Self {
Self { channel }
}
fn channel(&self) -> &Channel {
&self.channel
}
}
impl Disposable {
pub async fn dispose(&self) -> Result<(), ProtocolError> {
self.channel.send_no_result("dispose", &serde_json::json!({})).await
}
}