From 679f824c675025018f9778d9fd5ce21640ac22e4 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 18 Aug 2020 00:00:17 +0200 Subject: [PATCH] client-api: Add retry_after_ms field to ErrorKind::LimitExceeded --- ruma-client-api/src/error.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ruma-client-api/src/error.rs b/ruma-client-api/src/error.rs index 728f32a9..7f8e64d1 100644 --- a/ruma-client-api/src/error.rs +++ b/ruma-client-api/src/error.rs @@ -1,6 +1,9 @@ //! Errors that can be sent from the homeserver. -use std::fmt::{self, Display, Formatter}; +use std::{ + fmt::{self, Display, Formatter}, + time::Duration, +}; use ruma_api::{error::ResponseDeserializationError, EndpointError}; use ruma_identifiers::RoomVersionId; @@ -53,7 +56,11 @@ pub enum ErrorKind { /// M_LIMIT_EXCEEDED #[serde(rename = "M_LIMIT_EXCEEDED")] #[strum(to_string = "M_LIMIT_EXCEEDED")] - LimitExceeded, + LimitExceeded { + /// How long a client should wait in milliseconds before they can try again. + #[serde(with = "ruma_serde::duration::opt_ms")] + retry_after_ms: Option, + }, /// M_UNKNOWN #[serde(rename = "M_UNKNOWN")]