matrix_sdk/client/caches.rs
1// Copyright 2025 The Matrix.org Foundation C.I.C.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#[cfg(feature = "experimental-oidc")]
16use mas_oidc_client::types::oidc::VerifiedProviderMetadata;
17#[cfg(feature = "experimental-oidc")]
18use matrix_sdk_base::ttl_cache::TtlCache;
19use tokio::sync::RwLock;
20
21use super::ClientServerCapabilities;
22
23/// A collection of in-memory data that the `Client` might want to cache to
24/// avoid hitting the homeserver every time users request the data.
25pub(crate) struct ClientCaches {
26 /// Server capabilities, either prefilled during building or fetched from
27 /// the server.
28 pub(super) server_capabilities: RwLock<ClientServerCapabilities>,
29 #[cfg(feature = "experimental-oidc")]
30 pub(crate) provider_metadata: tokio::sync::Mutex<TtlCache<String, VerifiedProviderMetadata>>,
31}