Skip to content

Commit

Permalink
Fix incompatibiity with empth result handling.
Browse files Browse the repository at this point in the history
hub_handler returns Result<Option<R>, Error> for control_child().
  • Loading branch information
pwoerndle committed Nov 5, 2023
1 parent d1352d8 commit 10c919a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tapo/src/api/child_devices/t300_handler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::api::HubHandler;
use crate::error::Error;
use crate::error::{Error,TapoResponseError};
use crate::requests::{EmptyParams, GetTriggerLogsParams, TapoParams, TapoRequest};
use crate::responses::T300Result;
use crate::responses::{T300Log, TriggerLogsResult};
Expand All @@ -25,7 +25,8 @@ impl<'h> T300Handler<'h> {

self.hub_handler
.control_child(self.device_id.clone(), request)
.await
.await?
.ok_or_else(|| Error::Tapo(TapoResponseError::EmptyResult))
}

/// Returns a list of trigger logs.
Expand All @@ -44,8 +45,12 @@ impl<'h> T300Handler<'h> {
let child_params = GetTriggerLogsParams::new(page_size, start_id);
let child_request = TapoRequest::GetTriggerLogs(Box::new(TapoParams::new(child_params)));

self.hub_handler
.control_child(self.device_id.clone(), child_request)
.await
let result = self
.hub_handler
.control_child::<TriggerLogsResult<T300Log>>(self.device_id.clone(), child_request)
.await?
.ok_or_else(|| Error::Tapo(TapoResponseError::EmptyResult));

Ok(result?)
}
}

0 comments on commit 10c919a

Please sign in to comment.