termux/
call.rs

1use crate::*;
2use serde::Deserialize;
3
4#[derive(Deserialize, Debug, Clone)]
5pub struct CallLog {
6    pub name: String,
7    pub phone_number: String,
8    pub r#type: String,
9    pub date: String,
10    pub duration: String,
11}
12
13/// List call log history.
14///
15/// The args to the functions are the `offset` and `limit` in call log list respectively.
16pub fn log(offset: i32, limit: i32) -> io::Result<Vec<CallLog>> {
17    let out = run_api_cmd_with_args(
18        "CallLog",
19        &[
20            "--ei",
21            "offset",
22            &offset.to_string(),
23            "--ei",
24            "limit",
25            &limit.to_string(),
26        ],
27    )?;
28    Ok(serde_json::from_str(&out).unwrap())
29}
30
31#[test]
32fn test_log() {
33    assert!(log(10, 0).is_ok())
34}