Skip to content

Commit

Permalink
chore(types): add more api types to the api client
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricschwyter committed Jul 13, 2023
1 parent e373d1f commit 3ba77e2
Show file tree
Hide file tree
Showing 7 changed files with 475 additions and 241 deletions.
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.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ thiserror = "1.0.43"
specta = "1.0.4"
tauri-specta = { version = "1.0.2", features = ["javascript", "typescript"] }
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 @@ use tauri::State;

#[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 @@ get!(
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 @@ pub async fn set_selected_bridge(
#[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 @@ pub async fn get_discovered_bridges(

#[tauri::command]
#[specta::specta]
pub async fn abort_discover(state: State<'_, HueHueHueState>) -> Result<(), HueHueHueError> {
pub async fn abort_discover(state: State<'_, HueHueHueState>) -> Result<(), HueHueHueBackendError> {
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 @@ macro_rules! endpoint {
($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> {
#[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 @@ macro_rules! endpoint {

#[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> {
let huehuehue = state.0.lock().await;
crate::HueHueHue::[<$method:lower _ $endpointname>](&huehuehue $(,body as $body)? $(,$($param)+)?).await
}
Expand Down
Loading

0 comments on commit 3ba77e2

Please sign in to comment.