From 5aef53758269e35201cbf15c9c1eb06a71f44685 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 30 Apr 2020 15:28:42 +0200 Subject: [PATCH] impl Display for UiaaResponse --- src/r0/uiaa.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/r0/uiaa.rs b/src/r0/uiaa.rs index 3caa8afa..14b7a97a 100644 --- a/src/r0/uiaa.rs +++ b/src/r0/uiaa.rs @@ -1,6 +1,9 @@ //! Module for User-Interactive Authentication API types. -use std::collections::BTreeMap; +use std::{ + collections::BTreeMap, + fmt::{self, Display, Formatter}, +}; use ruma_api::{error::ResponseDeserializationError, EndpointError}; use serde::{Deserialize, Serialize}; @@ -74,6 +77,15 @@ pub enum UiaaResponse { MatrixError(MatrixError), } +impl Display for UiaaResponse { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + match self { + Self::AuthResponse(_) => write!(f, "User-Interactive Authentication required."), + Self::MatrixError(err) => write!(f, "{}", err), + } + } +} + impl From for UiaaResponse { fn from(error: MatrixError) -> Self { Self::MatrixError(error)