You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the tauri/src/hooks.rs, InvokeResponse is defined as an enum with two variants Ok and Err, which is equivalent to the Rust Result type. Not using directly a Result adds complexity to the code as it requires to implement many conversion from and into Result for InvokeResponse.
Describe the solution you'd like
The definition of InvokeResponse could be replaced by pub struct InvokeResponse(Result<JsonValue, InvokeError>);.
The commit 7db6a27 shows how such a refactoring would look like.
Alternatives considered
The definition of InvokeResponse could instead be replaced by pub type InvokeResponse = Result<JsonValue, InvokeError>; but this means that converting From<Result<T, InvokeError>> for InvokeResponse to InvokeResponse would be more complex than a simple call to into or from (because we cannot write impl for defined types).
Additional context
This complexity can lead to unoptimized cost. For example, PR #5639 fixes a bug where a JsonValue was serialized into a JsonValue uselessly because of the conversion from Result to InvokeResponse.
The text was updated successfully, but these errors were encountered:
Describe the problem
In the
tauri/src/hooks.rs
,InvokeResponse
is defined as an enum with two variantsOk
andErr
, which is equivalent to the RustResult
type. Not using directly aResult
adds complexity to the code as it requires to implement many conversion from and intoResult
forInvokeResponse
.Describe the solution you'd like
The definition of
InvokeResponse
could be replaced bypub struct InvokeResponse(Result<JsonValue, InvokeError>);
.The commit 7db6a27 shows how such a refactoring would look like.
Alternatives considered
The definition of
InvokeResponse
could instead be replaced bypub type InvokeResponse = Result<JsonValue, InvokeError>;
but this means that convertingFrom<Result<T, InvokeError>> for InvokeResponse
toInvokeResponse
would be more complex than a simple call tointo
orfrom
(because we cannot writeimpl
for defined types).Additional context
This complexity can lead to unoptimized cost. For example, PR #5639 fixes a bug where a
JsonValue
was serialized into aJsonValue
uselessly because of the conversion fromResult
toInvokeResponse
.The text was updated successfully, but these errors were encountered: