From 10c919a0282f37fa9069237f4cf64c4a7eba9d5a Mon Sep 17 00:00:00 2001 From: pwoerndle <21156233+pwoerndle@users.noreply.github.com> Date: Sun, 5 Nov 2023 11:59:10 +0000 Subject: [PATCH] Fix incompatibiity with empth result handling. hub_handler returns Result, Error> for control_child(). --- tapo/src/api/child_devices/t300_handler.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tapo/src/api/child_devices/t300_handler.rs b/tapo/src/api/child_devices/t300_handler.rs index b7b387e..cffe57d 100644 --- a/tapo/src/api/child_devices/t300_handler.rs +++ b/tapo/src/api/child_devices/t300_handler.rs @@ -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}; @@ -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. @@ -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::>(self.device_id.clone(), child_request) + .await? + .ok_or_else(|| Error::Tapo(TapoResponseError::EmptyResult)); + + Ok(result?) } }