From b695973d6ff69edcfbb341f4634c29353ee39969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 24 Apr 2026 09:16:49 +0200 Subject: [PATCH] refactor(sdk): Make Cache generic over the error type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For cases where the error doesn't need to be propagated. Signed-off-by: Kévin Commaille --- crates/matrix-sdk/src/client/caches.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/matrix-sdk/src/client/caches.rs b/crates/matrix-sdk/src/client/caches.rs index 6d38deb1f..a362da9c3 100644 --- a/crates/matrix-sdk/src/client/caches.rs +++ b/crates/matrix-sdk/src/client/caches.rs @@ -36,13 +36,13 @@ pub(crate) struct ClientCaches { /// /// - The versions prefilled with `ClientBuilder::server_versions()` /// - The versions fetched from an *authenticated* request to the server. - pub(crate) supported_versions: Cache, + pub(crate) supported_versions: Cache>, /// Well-known information. - pub(super) well_known: Cache>, + pub(super) well_known: Cache, ()>, /// OAuth 2.0 server metadata. - pub(crate) server_metadata: Cache, + pub(crate) server_metadata: Cache, /// Homeserver capabilities. - pub(crate) homeserver_capabilities: Cache, + pub(crate) homeserver_capabilities: Cache>, } /// A cached value that can either be set or not set, used to avoid confusion @@ -70,16 +70,16 @@ impl CachedValue { } /// A cache in the [`ClientCaches`]. -pub(crate) struct Cache { +pub(crate) struct Cache { /// The value that is cached. value: Mutex>>, /// Lock making sure that we are only refreshing the value once at a time. /// /// Stores the error that happened during the last refresh, if any. - pub(crate) refresh_lock: AsyncMutex>>, + pub(crate) refresh_lock: AsyncMutex>, } -impl Cache { +impl Cache { /// Construct a new empty `Cache`. pub(crate) fn new() -> Self { Self::with_value(CachedValue::NotSet) @@ -101,7 +101,7 @@ impl Cache { } } -impl Cache +impl Cache where Value: Clone, {