Skip to content

Conversation

@oguzkocer
Copy link
Contributor

Since api discovery is done through multiple attempts, it can be a little difficult to work with its result especially when it results in an error. To help combat this, this PR introduces the concept of "error importance" for AutoDiscoveryAttemptFailure so that we can identify which error would be the most useful to share with the user. This is currently closely related to when the error occurs in the api discovery process where the errors from later steps are treated as more important.

This concept is applied as a helper in the Rust API using the new combined_result function. However, for native clients, it removes the previous AutoDiscoveryUniffiResult in favor of directly returning this combined result. This means the clients can no longer show the result of each attempt, but that wasn't being useful at the moment. If we ever want to make the result of all attempts available, it'll be a simple change.

@oguzkocer oguzkocer added this to the 0.2 milestone Apr 7, 2025
@oguzkocer oguzkocer enabled auto-merge (squash) April 7, 2025 23:14
// Sort in descending order so the most important error is returned
.sorted_by(|a, b| b.compare_importance(a))
.next()
.expect("If the discovery was unsuccessful, there is at least one error"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I think you can get rid of this unnecessary expect if deleting find_successful and re-implementing it within this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that, but that function should still be useful for Rust clients. I also considered duplicating the implementation, but the expect didn't bother me enough to do that 🤷

@oguzkocer oguzkocer merged commit 41da7a4 into trunk Apr 8, 2025
14 of 20 checks passed
@oguzkocer oguzkocer deleted the simplify-uniffi-api-discovery-result branch April 8, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants