From d4fb528c14689263635b006e332cbca8d59d196a Mon Sep 17 00:00:00 2001 From: Vika Date: Sat, 24 Aug 2024 21:45:15 +0300 Subject: kittybox-indieauth: nicer Debug impl for Metadata Now the URLs are shown in their serialized form. --- indieauth/src/lib.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'indieauth/src') diff --git a/indieauth/src/lib.rs b/indieauth/src/lib.rs index c393b3d..b3ec098 100644 --- a/indieauth/src/lib.rs +++ b/indieauth/src/lib.rs @@ -141,7 +141,7 @@ pub enum GrantType { /// client_id_metadata_document_supported: true, /// }; /// ``` -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Clone, Serialize, Deserialize)] pub struct Metadata { /// The server's issuer identifier. The issuer identifier is a URL /// that uses the "https" scheme and has no query or fragment @@ -225,6 +225,28 @@ pub struct Metadata { pub client_id_metadata_document_supported: bool } +impl std::fmt::Debug for Metadata { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Metadata") + .field("issuer", &self.issuer.as_str()) + .field("authorization_endpoint", &self.issuer.as_str()) + .field("token_endpoint", &self.issuer.as_str()) + .field("introspection_endpoint", &self.issuer.as_str()) + .field("introspection_endpoint_auth_methods_supported", &self.introspection_endpoint_auth_methods_supported) + .field("revocation_endpoint", &self.revocation_endpoint.as_ref().map(Url::as_str)) + .field("revocation_endpoint_auth_methods_supported", &self.revocation_endpoint_auth_methods_supported) + .field("scopes_supported", &self.scopes_supported) + .field("response_types_supported", &self.response_types_supported) + .field("grant_types_supported", &self.grant_types_supported) + .field("service_documentation", &self.service_documentation.as_ref().map(Url::as_str)) + .field("code_challenge_methods_supported", &self.code_challenge_methods_supported) + .field("authorization_response_iss_parameter_supported", &self.authorization_response_iss_parameter_supported) + .field("userinfo_endpoint", &self.userinfo_endpoint.as_ref().map(Url::as_str)) + .field("client_id_metadata_document_supported", &self.client_id_metadata_document_supported) + .finish() + } +} + fn ref_identity(v: &bool) -> bool { *v } #[cfg(feature = "axum")] -- cgit 1.4.1