Skip to content

Commit

Permalink
Rename __Result__ to Result -
Browse files Browse the repository at this point in the history
  • Loading branch information
oscartbeaumont committed Apr 30, 2024
1 parent 38ec0e0 commit 5296bde
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
4 changes: 2 additions & 2 deletions examples/app/src/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ return await TAURI_INVOKE("hello_world", { myName });
async goodbyeWorld() : Promise<string> {
return await TAURI_INVOKE("goodbye_world");
},
async hasError() : Promise<__Result__<string, number>> {
async hasError() : Promise<Result<string, number>> {
try {
return { status: "ok", data: await TAURI_INVOKE("has_error") };
} catch (e) {
Expand Down Expand Up @@ -60,7 +60,7 @@ type __EventObj__<T> = {
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
};

export type __Result__<T, E> =
export type Result<T, E> =
| { status: "ok"; data: T }
| { status: "error"; error: E };

Expand Down
32 changes: 15 additions & 17 deletions examples/custom-plugin/plugin/bindings.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.

export const commands = {
/**
* Adds two numbers, returning the result.
*/
async addNumbers(a: number, b: number) : Promise<number> {
return await TAURI_INVOKE("plugin:custom-plugin|add_numbers", { a, b });
}
}
export const commands = {
/**
* Adds two numbers, returning the result.
*/
async addNumbers(a: number, b: number): Promise<number> {
return await TAURI_INVOKE("plugin:custom-plugin|add_numbers", { a, b });
},
};

export const events = __makeEvents__<{
randomNumber: RandomNumber
randomNumber: RandomNumber;
}>({
randomNumber: "plugin:custom-plugin:random-number"
})
randomNumber: "plugin:custom-plugin:random-number",
});

/** user-defined types **/

export type RandomNumber = number
export type RandomNumber = number;

/** tauri-specta globals **/

import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core";
import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core";
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";

Expand All @@ -37,7 +37,7 @@ type __EventObj__<T> = {
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
};

export type __Result__<T, E> =
export type Result<T, E> =
| { status: "ok"; data: T }
| { status: "error"; error: E };

Expand Down Expand Up @@ -75,5 +75,3 @@ function __makeEvents__<T extends Record<string, any>>(
}
);
}


2 changes: 1 addition & 1 deletion src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as TAURI_API_EVENT from "@tauri-apps/api/event";

/**
* @template T,E
* @typedef { { status: "ok", data: T } | { status: "error", error: E } } __Result__
* @typedef { { status: "ok", data: T } | { status: "error", error: E } } Result
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type __EventObj__<T> = {
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
};

export type __Result__<T, E> =
export type Result<T, E> =
| { status: "ok"; data: T }
| { status: "error"; error: E };

Expand Down
2 changes: 1 addition & 1 deletion src/js_ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn handle_result(
let (t, e) = t.as_ref();

format!(
"__Result__<{}, {}>",
"Result<{}, {}>",
ts::datatype(&cfg.inner, t, type_map)?,
ts::datatype(&cfg.inner, e, type_map)?
)
Expand Down

0 comments on commit 5296bde

Please sign in to comment.