appium_client/commands/
time.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 HasDeviceTime : AppiumClientTrait {
12
13 async fn device_time(&self) -> Result<String, CmdError> {
16 let value = self.issue_cmd(AppiumCommand::Custom(
17 Method::GET,
18 "appium/device/system_time".to_string(),
19 None
20 )).await?;
21
22 Ok(serde_json::from_value(value)?)
23 }
24
25 async fn device_time_with_format(&self, format: &str) -> Result<String, CmdError> {
30 let value = self.execute("mobile: getDeviceTime", vec![
31 json!({"format": format})
32 ]).await?;
33
34 Ok(serde_json::from_value(value)?)
35 }
36}
37
38#[async_trait]
39impl HasDeviceTime for AndroidClient {}
40
41#[async_trait]
42impl HasDeviceTime for IOSClient {}