openidconnect-rs
openidconnect-rs copied to clipboard
FR: Conversion Trait implementation for configuration types
Feature Request
Implement std::str::FromStr or From<String> for commonly used configuration types:
IssuerUrlClientIdClientSecretRedirectUrl
(maybe more?)
Use Case/Context
This would make it much more ergonomic to load those values from the environment or config files, e.g. when using frameworks like envconfig or serde.
Hi @ramosbugs, I want to implement this, but before I start investing time, is this something you'd be willing to merge?
(Edit: of course here and in https://github.com/ramosbugs/oauth2-rs)
Looking at the code, it might make sense to implement this directly in the new_type! and new_url_type! macros.
the NewType pattern used in these two crates intentionally omits such convenience interfaces in favor of explicitness for the reasons outlined here: https://github.com/ramosbugs/oauth2-rs/issues/112#issuecomment-675801545
This would make it much more ergonomic to load those values from the environment or config files, e.g. when using frameworks like envconfig or
serde.
the types do implement Serialize and Deserialize for serde. for other use cases, the code will need to explicitly cast lower-level strings to these higher-level abstractions.