Skip to content

Commit

Permalink
Improve ApiClient::new ergonomics
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-dinculescu committed Feb 24, 2024
1 parent e8f506b commit f06b6b8
Show file tree
Hide file tree
Showing 20 changed files with 163 additions and 118 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ file. This change log follows the conventions of

## [Rust Unreleased][Unreleased]

### Changed

- The implementation of `ApiClient::new` has been improved to allow for the return of `ApiClient` instead of `Result<ApiClient, Error>`.
- The default timeout for all requests has been reduced to 30 seconds from 300 seconds.

## [Python Unreleased][Unreleased]

## [Rust v0.7.9][v0.7.9] - 2024-01-27
Expand Down
2 changes: 1 addition & 1 deletion tapo-py/src/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct PyApiClient {
impl PyApiClient {
#[new]
pub fn new(tapo_username: String, tapo_password: String) -> Result<Self, ErrorWrapper> {
let client = ApiClient::new(tapo_username, tapo_password)?;
let client = ApiClient::new(tapo_username, tapo_password);
Ok(Self { client })
}

Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_generic_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tapo_password = env::var("TAPO_PASSWORD")?;
let ip_address = env::var("IP_ADDRESS")?;

let device = ApiClient::new(tapo_username, tapo_password)?
let device = ApiClient::new(tapo_username, tapo_password)
.generic_device(ip_address)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_generic_device_toggle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tapo_password = env::var("TAPO_PASSWORD")?;
let ip_address = env::var("IP_ADDRESS")?;

let device = ApiClient::new(tapo_username, tapo_password)?
let device = ApiClient::new(tapo_username, tapo_password)
.generic_device(ip_address)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_h100.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tapo_password = env::var("TAPO_PASSWORD")?;
let ip_address = env::var("IP_ADDRESS")?;

let hub = ApiClient::new(tapo_username, tapo_password)?
let hub = ApiClient::new(tapo_username, tapo_password)
.h100(ip_address)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_ke100.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let device_id = env::var("DEVICE_ID")?;
let target_temperature: u8 = env::var("TARGET_TEMPERATURE")?.parse()?;

let hub = ApiClient::new(tapo_username, tapo_password)?
let hub = ApiClient::new(tapo_username, tapo_password)
.h100(ip_address)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_l510.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tapo_password = env::var("TAPO_PASSWORD")?;
let ip_address = env::var("IP_ADDRESS")?;

let device = ApiClient::new(tapo_username, tapo_password)?
let device = ApiClient::new(tapo_username, tapo_password)
.l510(ip_address)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_l530.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tapo_password = env::var("TAPO_PASSWORD")?;
let ip_address = env::var("IP_ADDRESS")?;

let device = ApiClient::new(tapo_username, tapo_password)?
let device = ApiClient::new(tapo_username, tapo_password)
.l530(ip_address)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_l930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tapo_password = env::var("TAPO_PASSWORD")?;
let ip_address = env::var("IP_ADDRESS")?;

let device = ApiClient::new(tapo_username, tapo_password)?
let device = ApiClient::new(tapo_username, tapo_password)
.l930(ip_address)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_p100.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tapo_password = env::var("TAPO_PASSWORD")?;
let ip_address = env::var("IP_ADDRESS")?;

let device = ApiClient::new(tapo_username, tapo_password)?
let device = ApiClient::new(tapo_username, tapo_password)
.p100(ip_address)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion tapo/examples/tapo_p110.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let tapo_password = env::var("TAPO_PASSWORD")?;
let ip_address = env::var("IP_ADDRESS")?;

let device = ApiClient::new(tapo_username, tapo_password)?
let device = ApiClient::new(tapo_username, tapo_password)
.p110(ip_address)
.await?;

Expand Down
Loading

0 comments on commit f06b6b8

Please sign in to comment.