197g / 197g/oxide-auth

Let `oxide_auth_rocket::OAuthFailure` be a `#[non_exhaustive]` enum

Offen
#118 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
improvement
Vorherrschende Sprache
Rust
Sterne
783
Forks
102
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

# Project Improvement

Currently `oxide_auth_rocket::OAuthFailure` is a struct with a private inner field `Kind` which one can retrieve variants from via the `oauth()` and `web()` methods. If you want to roll your own error type (since `OAuthFailure` is not stable) you have to do some cumbersome matching that feels a bit un-rusty:

```
if let Some(web_failure) = failure.web() {
//...
} else if let Some(oauth_failure) = failure.oauth() {
//...
}
```

Turning the failure type into a non-exhaustive enum would allow users to match on the enum instead of having to call functions while still allowing the project to add new failure modes.

## Other context

It just feels like a more ergonomic interface to use.

# Tracking pull request

- [ ] A pull request does not yet exist, I could create it if this seems like a reasonable request.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.