Skip to content

Commit

Permalink
Merge pull request #19 from KyrillGobber/tauri_specta
Browse files Browse the repository at this point in the history
first steps tauri-specta
  • Loading branch information
KyrillGobber authored Jun 30, 2023
2 parents a024877 + 3f56e66 commit dd64ad8
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 96 deletions.
96 changes: 96 additions & 0 deletions src-tauri/Cargo.lock

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

2 changes: 2 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ reqwest = { version = "0.11.18", features = ["json"] }
paste = "1.0.12"
serde_derive = "1.0.164"
thiserror = "1.0.40"
specta = "1.0.4"
tauri-specta = { version = "1.0.2", features = ["javascript", "typescript"] }

[features]
# this feature is used for production builds or when `devPath` points to the filesystem
Expand Down
8 changes: 8 additions & 0 deletions src-tauri/core/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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> {
let huehuehue = state.0.lock().await;
crate::HueHueHue::[<$method:lower _ $endpointname>](&huehuehue $(,body as $body)? $(,$($param)+)?).await
Expand Down Expand Up @@ -84,6 +85,13 @@ macro_rules! patch {

macro_rules! handlers {
($($handler:ident),*) => {
#[macro_export]
macro_rules! bindings {
($path:expr) => {
#[cfg(debug_assertions)]
tauri_specta::ts::export(specta::collect_types![$($handler,)*], $path).unwrap();
};
}
#[macro_export]
macro_rules! huehuehue_handlers {
($app:expr) => {
Expand Down
Loading

0 comments on commit dd64ad8

Please sign in to comment.