mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Add interval timeout to heartbeat
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -424,7 +424,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "idevice"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"env_logger",
|
||||
"log",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name = "idevice"
|
||||
description = "A Rust library to interact with services on iOS devices."
|
||||
authors = ["Jackson Coxson"]
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
documentation = "https://docs.rs/idevice"
|
||||
|
||||
@@ -12,8 +12,14 @@ impl HeartbeatClient {
|
||||
Self { idevice }
|
||||
}
|
||||
|
||||
pub async fn get_marco(&mut self) -> Result<u64, IdeviceError> {
|
||||
let rec = self.idevice.read_plist().await?;
|
||||
pub async fn get_marco(&mut self, interval: u64) -> Result<u64, IdeviceError> {
|
||||
// Get a plist or wait for the interval
|
||||
let rec = tokio::select! {
|
||||
rec = self.idevice.read_plist() => rec?,
|
||||
_ = tokio::time::sleep(tokio::time::Duration::from_secs(interval)) => {
|
||||
return Err(IdeviceError::HeartbeatTimeout)
|
||||
}
|
||||
};
|
||||
match rec.get("Interval") {
|
||||
Some(plist::Value::Integer(interval)) => {
|
||||
if let Some(interval) = interval.as_unsigned() {
|
||||
|
||||
@@ -141,6 +141,8 @@ pub enum IdeviceError {
|
||||
NoEstablishedConnection,
|
||||
#[error("device went to sleep")]
|
||||
HeartbeatSleepyTime,
|
||||
#[error("heartbeat timeout")]
|
||||
HeartbeatTimeout,
|
||||
#[error("not found")]
|
||||
NotFound,
|
||||
#[error("unknown error `{0}` returned from device")]
|
||||
|
||||
Reference in New Issue
Block a user