#![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 AndroidInitializer {}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidDevicesParams {
#[serde(rename = "host", default, skip_serializing_if = "Option::is_none")]
pub host: Option<String>,
#[serde(rename = "port", default, skip_serializing_if = "Option::is_none")]
pub port: Option<i64>,
#[serde(rename = "omitDriverInstall", default, skip_serializing_if = "Option::is_none")]
pub omit_driver_install: Option<bool>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidDevicesResult {
#[serde(rename = "devices")]
pub devices: Vec<Ref<AndroidDevice>>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum AndroidEvent {
Unknown {
method: String,
params: serde_json::Value,
},
}
impl ProtocolEvent for AndroidEvent {
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 Android {
channel: Channel,
}
impl ChannelType for Android {
const INTERFACE: &'static str = "Android";
type Initializer = AndroidInitializer;
type Event = AndroidEvent;
fn accepts(interface: &str) -> bool {
matches!(interface, "Android")
}
fn from_channel(channel: Channel) -> Self {
Self { channel }
}
fn channel(&self) -> &Channel {
&self.channel
}
}
impl Android {
pub async fn devices(&self, params: AndroidDevicesParams) -> Result<AndroidDevicesResult, ProtocolError> {
self.channel.send("devices", ¶ms).await
}
}