pub struct ApiClient { /* private fields */ }Expand description
Implementations§
Source§impl ApiClient
Tapo API Client constructor.
impl ApiClient
Tapo API Client constructor.
Sourcepub fn new(
tapo_username: impl Into<String>,
tapo_password: impl Into<String>,
) -> ApiClient
pub fn new( tapo_username: impl Into<String>, tapo_password: impl Into<String>, ) -> ApiClient
Returns a new instance of ApiClient.
It is cheaper to ApiClient::clone an existing instance than to create a new one when multiple devices need to be controller.
This is because ApiClient::clone reuses the underlying reqwest::Client.
§Arguments
tapo_username- the Tapo usernametapo_password- the Tapo password
Note: The default connection timeout is 30 seconds.
Use ApiClient::with_timeout to change it.
Sourcepub fn with_timeout(self, timeout: Duration) -> ApiClient
pub fn with_timeout(self, timeout: Duration) -> ApiClient
Changes the connection timeout from the default value to the given value.
§Arguments
timeout- The new connection timeout value.
Sourcepub async fn discover_devices(
self,
target: impl Into<String>,
timeout_s: u64,
) -> Result<DeviceDiscovery, Error>
pub async fn discover_devices( self, target: impl Into<String>, timeout_s: u64, ) -> Result<DeviceDiscovery, Error>
Discovers one or more devices located at a specified unicast or broadcast IP address.
§Arguments
target- The IP address at which the discovery will take place. This address can be either a unicast (e.g.192.168.1.10) or a broadcast address (e.g.192.168.1.255,255.255.255.255, etc.).timeout_s- The maximum time to wait for a response from the device(s) in seconds. Must be between1and60.
Source§impl ApiClient
Device handler builders.
impl ApiClient
Device handler builders.
Sourcepub async fn generic_device(
self,
ip_address: impl Into<String>,
) -> Result<GenericDeviceHandler, Error>
pub async fn generic_device( self, ip_address: impl Into<String>, ) -> Result<GenericDeviceHandler, Error>
Specializes the given ApiClient into an authenticated GenericDeviceHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.generic_device("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn l510(
self,
ip_address: impl Into<String>,
) -> Result<LightHandler, Error>
pub async fn l510( self, ip_address: impl Into<String>, ) -> Result<LightHandler, Error>
Specializes the given ApiClient into an authenticated LightHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.l510("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn l520(
self,
ip_address: impl Into<String>,
) -> Result<LightHandler, Error>
pub async fn l520( self, ip_address: impl Into<String>, ) -> Result<LightHandler, Error>
Specializes the given ApiClient into an authenticated LightHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.l520("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn l530(
self,
ip_address: impl Into<String>,
) -> Result<ColorLightHandler, Error>
pub async fn l530( self, ip_address: impl Into<String>, ) -> Result<ColorLightHandler, Error>
Specializes the given ApiClient into an authenticated ColorLightHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.l530("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn l535(
self,
ip_address: impl Into<String>,
) -> Result<ColorLightHandler, Error>
pub async fn l535( self, ip_address: impl Into<String>, ) -> Result<ColorLightHandler, Error>
Specializes the given ApiClient into an authenticated ColorLightHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.l535("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn l610(
self,
ip_address: impl Into<String>,
) -> Result<LightHandler, Error>
pub async fn l610( self, ip_address: impl Into<String>, ) -> Result<LightHandler, Error>
Specializes the given ApiClient into an authenticated LightHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.l610("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn l630(
self,
ip_address: impl Into<String>,
) -> Result<ColorLightHandler, Error>
pub async fn l630( self, ip_address: impl Into<String>, ) -> Result<ColorLightHandler, Error>
Specializes the given ApiClient into an authenticated ColorLightHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.l630("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn l900(
self,
ip_address: impl Into<String>,
) -> Result<RgbLightStripHandler, Error>
pub async fn l900( self, ip_address: impl Into<String>, ) -> Result<RgbLightStripHandler, Error>
Specializes the given ApiClient into an authenticated RgbLightStripHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.l900("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn l920(
self,
ip_address: impl Into<String>,
) -> Result<RgbicLightStripHandler, Error>
pub async fn l920( self, ip_address: impl Into<String>, ) -> Result<RgbicLightStripHandler, Error>
Specializes the given ApiClient into an authenticated RgbicLightStripHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.l920("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn l930(
self,
ip_address: impl Into<String>,
) -> Result<RgbicLightStripHandler, Error>
pub async fn l930( self, ip_address: impl Into<String>, ) -> Result<RgbicLightStripHandler, Error>
Specializes the given ApiClient into an authenticated RgbicLightStripHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.l930("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn p100(
self,
ip_address: impl Into<String>,
) -> Result<PlugHandler, Error>
pub async fn p100( self, ip_address: impl Into<String>, ) -> Result<PlugHandler, Error>
Specializes the given ApiClient into an authenticated PlugHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.p100("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn p105(
self,
ip_address: impl Into<String>,
) -> Result<PlugHandler, Error>
pub async fn p105( self, ip_address: impl Into<String>, ) -> Result<PlugHandler, Error>
Specializes the given ApiClient into an authenticated PlugHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.p105("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn p110(
self,
ip_address: impl Into<String>,
) -> Result<PlugEnergyMonitoringHandler, Error>
pub async fn p110( self, ip_address: impl Into<String>, ) -> Result<PlugEnergyMonitoringHandler, Error>
Specializes the given ApiClient into an authenticated PlugEnergyMonitoringHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.p110("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn p115(
self,
ip_address: impl Into<String>,
) -> Result<PlugEnergyMonitoringHandler, Error>
pub async fn p115( self, ip_address: impl Into<String>, ) -> Result<PlugEnergyMonitoringHandler, Error>
Specializes the given ApiClient into an authenticated PlugEnergyMonitoringHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.p115("192.168.1.100")
.await?;
device.on().await?;Sourcepub async fn p300(
self,
ip_address: impl Into<String>,
) -> Result<PowerStripHandler, Error>
pub async fn p300( self, ip_address: impl Into<String>, ) -> Result<PowerStripHandler, Error>
Specializes the given ApiClient into an authenticated PowerStripHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.p300("192.168.1.100")
.await?;
let child_device_list = device.get_child_device_list().await?;
println!("Child device list: {child_device_list:?}");Sourcepub async fn p304(
self,
ip_address: impl Into<String>,
) -> Result<PowerStripEnergyMonitoringHandler, Error>
pub async fn p304( self, ip_address: impl Into<String>, ) -> Result<PowerStripEnergyMonitoringHandler, Error>
Specializes the given ApiClient into an authenticated PowerStripEnergyMonitoringHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.p304("192.168.1.100")
.await?;
let child_device_list = device.get_child_device_list().await?;
println!("Child device list: {child_device_list:?}");Sourcepub async fn p306(
self,
ip_address: impl Into<String>,
) -> Result<PowerStripHandler, Error>
pub async fn p306( self, ip_address: impl Into<String>, ) -> Result<PowerStripHandler, Error>
Specializes the given ApiClient into an authenticated PowerStripHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.p306("192.168.1.100")
.await?;
let child_device_list = device.get_child_device_list().await?;
println!("Child device list: {child_device_list:?}");Sourcepub async fn p316(
self,
ip_address: impl Into<String>,
) -> Result<PowerStripEnergyMonitoringHandler, Error>
pub async fn p316( self, ip_address: impl Into<String>, ) -> Result<PowerStripEnergyMonitoringHandler, Error>
Specializes the given ApiClient into an authenticated PowerStripEnergyMonitoringHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.p316("192.168.1.100")
.await?;
let child_device_list = device.get_child_device_list().await?;
println!("Child device list: {child_device_list:?}");Sourcepub async fn h100(
self,
ip_address: impl Into<String>,
) -> Result<HubHandler, Error>
pub async fn h100( self, ip_address: impl Into<String>, ) -> Result<HubHandler, Error>
Specializes the given ApiClient into an authenticated HubHandler.
§Arguments
ip_address- the IP address of the device
§Example
let device = ApiClient::new("tapo-username@example.com", "tapo-password")
.h100("192.168.1.100")
.await?;
let child_device_list = device.get_child_device_list().await?;
println!("Child device list: {child_device_list:?}");Trait Implementations§
Source§impl ApiClientExt for ApiClient
impl ApiClientExt for ApiClient
Source§fn set_device_info<'life0, 'async_trait>(
&'life0 self,
device_info_params: Value,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_device_info<'life0, 'async_trait>(
&'life0 self,
device_info_params: Value,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for ApiClient
impl !RefUnwindSafe for ApiClient
impl Send for ApiClient
impl Sync for ApiClient
impl Unpin for ApiClient
impl UnsafeUnpin for ApiClient
impl !UnwindSafe for ApiClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more