Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(types): add more api types to the api client #9

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ serde_derive = "1.0.164"
thiserror = "1.0.44"
specta = "1.0.5"
tauri-specta = { version = "1.0.2", features = ["javascript", "typescript"] }
clap = { version = "4.3.19", features = ["derive"] }
clap = { version = "4.3.11", features = ["derive"] }
futures = "0.3.28"

[features]
# this feature is used for production builds or when `devPath` points to the filesystem
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/core/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#[allow(unused_imports)]
use crate::core::transfer::*;
use crate::{HueHueHueError, HueHueHueState};
use crate::{HueHueHueBackendError, HueHueHueState};

get!("/resource/light", lights, HueV2LightResponse);
get!("/resource/light/{id}", light, HueV2LightResponse, [id]);
Expand Down Expand Up @@ -226,7 +226,7 @@
pub async fn set_selected_bridge(
mdns_name: String,
state: State<'_, HueHueHueState>,
) -> Result<(), HueHueHueError> {
) -> Result<(), HueHueHueBackendError> {
let mut huehuehue = state.0.lock().await;
huehuehue.set_selected_bridge(mdns_name)?;

Expand All @@ -237,7 +237,7 @@
#[specta::specta]
pub async fn get_discovered_bridges(
state: State<'_, HueHueHueState>,
) -> Result<Vec<(String, IpAddr)>, HueHueHueError> {
) -> Result<Vec<(String, IpAddr)>, HueHueHueBackendError> {
let huehuehue = state.0.lock().await;

Ok(huehuehue
Expand All @@ -250,7 +250,7 @@

#[tauri::command]
#[specta::specta]
pub async fn abort_discover(state: State<'_, HueHueHueState>) -> Result<(), HueHueHueError> {
pub async fn abort_discover(state: State<'_, HueHueHueState>) -> Result<(), HueHueHueBackendError> {

Check warning on line 253 in src-tauri/core/handlers.rs

View check run for this annotation

Codecov / codecov/patch

src-tauri/core/handlers.rs#L253

Added line #L253 was not covered by tests
let mut huehuehue = state.0.lock().await;

huehuehue.abort_discover()
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/core/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
($method:expr, $endpoint:expr, $endpointname:ident, $returntype:ident $(, $body:ident)? $(, [$($param:expr),+])?) => {
paste::paste! {
impl crate::HueHueHue {
pub async fn [<$method:lower _ $endpointname>](&self $(, body: $body)? $(, $($param: impl Into<String>),+)?) -> Result<$returntype, crate::HueHueHueError> {
pub async fn [<$method:lower _ $endpointname>](&self $(, body: $body)? $(, $($param: impl Into<String>),+)?) -> Result<$returntype, crate::HueHueHueBackendError> {

Check warning on line 7 in src-tauri/core/macros.rs

View check run for this annotation

Codecov / codecov/patch

src-tauri/core/macros.rs#L7

Added line #L7 was not covered by tests
#[allow(unused_mut)]
let mut endpoint: String = $endpoint.into();
$($(endpoint = endpoint.replace(format!("{{{}}}", stringify!($param)).as_str(), $param.into().as_str()));+;)?
Expand All @@ -21,7 +21,7 @@

#[tauri::command]
#[specta::specta]
pub async fn [<$method:lower _ $endpointname>]($(body: $body, )? $($($param: String),+,)? state: tauri::State<'_, crate::HueHueHueState>) -> Result<$returntype, crate::HueHueHueError> {
pub async fn [<$method:lower _ $endpointname>]($(body: $body, )? $($($param: String),+,)? state: tauri::State<'_, crate::HueHueHueState>) -> Result<$returntype, crate::HueHueHueBackendError> {

Check warning on line 24 in src-tauri/core/macros.rs

View check run for this annotation

Codecov / codecov/patch

src-tauri/core/macros.rs#L24

Added line #L24 was not covered by tests
let huehuehue = state.0.lock().await;
crate::HueHueHue::[<$method:lower _ $endpointname>](&huehuehue $(,body as $body)? $(,$($param)+)?).await
}
Expand Down
Loading
Loading