appium_client/commands/
lock.rs1use async_trait::async_trait;
3use fantoccini::error::CmdError;
4use http::Method;
5use serde_json::json;
6use crate::{AndroidClient, AppiumClientTrait, IOSClient};
7use crate::commands::AppiumCommand;
8
9#[async_trait]
11pub trait LocksDevice: AppiumClientTrait {
12
13 async fn lock_device(&self) -> Result<(), CmdError> {
15 self.issue_cmd(AppiumCommand::Custom(
16 Method::POST,
17 "appium/device/lock".to_string(),
18 Some(json!({}))
19 )).await?;
20
21 Ok(())
22 }
23}
24
25#[async_trait]
27pub trait UnlocksDevice: AppiumClientTrait {
28
29 async fn unlock_device(&self) -> Result<(), CmdError> {
34 self.issue_cmd(AppiumCommand::Custom(
35 Method::POST,
36 "appium/device/unlock".to_string(),
37 None
38 )).await?;
39
40 Ok(())
41 }
42}
43
44#[async_trait]
45impl LocksDevice for AndroidClient {}
46
47#[async_trait]
48impl LocksDevice for IOSClient {}
49
50#[async_trait]
51impl UnlocksDevice for AndroidClient {}