Open InputUsername opened 2 years ago
I really like this approach. Would you like me to rebase the branch against mainline?
Thinking of using the same approach for my Rust crate for Starling Bank.
Would you like me to rebase the branch against mainline?
Sure, go ahead. I'm very busy at the moment but I might have time to look into it soon.
We can use the "typestate pattern" to enforce authentication at compile time. To do this, we can make the
ListenBrainz
type generic over authentication status using a marker trait (eg.AuthStatus
). AListenBrainz<NotAuthenticated>
instance then first has to be authenticated to obtain aListenBrainz<Authenticated>
, which can perform methods that require authentication.I've implemented a proof-of-concept of this in the
feature/static-auth
branch.Thoughts?