@@ -22,6 +22,7 @@ use std::{
22
22
sync:: { Arc , Mutex as StdMutex , RwLock as StdRwLock , Weak } ,
23
23
} ;
24
24
25
+ use caches:: ClientCaches ;
25
26
use eyeball:: { SharedObservable , Subscriber } ;
26
27
use eyeball_im:: { Vector , VectorDiff } ;
27
28
use futures_core:: Stream ;
@@ -103,6 +104,7 @@ use crate::{
103
104
} ;
104
105
105
106
mod builder;
107
+ pub ( crate ) mod caches;
106
108
pub ( crate ) mod futures;
107
109
108
110
pub use self :: builder:: { sanitize_server_name, ClientBuildError , ClientBuilder } ;
@@ -263,9 +265,8 @@ pub(crate) struct ClientInner {
263
265
/// User session data.
264
266
pub ( super ) base_client : BaseClient ,
265
267
266
- /// Server capabilities, either prefilled during building or fetched from
267
- /// the server.
268
- server_capabilities : RwLock < ClientServerCapabilities > ,
268
+ /// Collection of in-memory caches for the [`Client`].
269
+ pub ( crate ) caches : ClientCaches ,
269
270
270
271
/// Collection of locks individual client methods might want to use, either
271
272
/// to ensure that only a single call to a method happens at once or to
@@ -351,16 +352,18 @@ impl ClientInner {
351
352
#[ cfg( feature = "e2e-encryption" ) ] encryption_settings : EncryptionSettings ,
352
353
cross_process_store_locks_holder_name : String ,
353
354
) -> Arc < Self > {
355
+ let caches = ClientCaches { server_capabilities : server_capabilities. into ( ) } ;
356
+
354
357
let client = Self {
355
358
server,
356
359
homeserver : StdRwLock :: new ( homeserver) ,
357
360
auth_ctx,
358
361
sliding_sync_version : StdRwLock :: new ( sliding_sync_version) ,
359
362
http_client,
360
363
base_client,
364
+ caches,
361
365
locks : Default :: default ( ) ,
362
366
cross_process_store_locks_holder_name,
363
- server_capabilities : RwLock :: new ( server_capabilities) ,
364
367
typing_notice_times : Default :: default ( ) ,
365
368
event_handlers : Default :: default ( ) ,
366
369
notification_handlers : Default :: default ( ) ,
@@ -1730,7 +1733,7 @@ impl Client {
1730
1733
& self ,
1731
1734
f : F ,
1732
1735
) -> HttpResult < T > {
1733
- let caps = & self . inner . server_capabilities ;
1736
+ let caps = & self . inner . caches . server_capabilities ;
1734
1737
if let Some ( val) = f ( & * caps. read ( ) . await ) {
1735
1738
return Ok ( val) ;
1736
1739
}
@@ -1799,7 +1802,7 @@ impl Client {
1799
1802
/// functions makes it possible to force reset it.
1800
1803
pub async fn reset_server_capabilities ( & self ) -> Result < ( ) > {
1801
1804
// Empty the in-memory caches.
1802
- let mut guard = self . inner . server_capabilities . write ( ) . await ;
1805
+ let mut guard = self . inner . caches . server_capabilities . write ( ) . await ;
1803
1806
guard. server_versions = None ;
1804
1807
guard. unstable_features = None ;
1805
1808
@@ -2421,7 +2424,7 @@ impl Client {
2421
2424
. base_client
2422
2425
. clone_with_in_memory_state_store ( & cross_process_store_locks_holder_name)
2423
2426
. await ?,
2424
- self . inner . server_capabilities . read ( ) . await . clone ( ) ,
2427
+ self . inner . caches . server_capabilities . read ( ) . await . clone ( ) ,
2425
2428
self . inner . respect_login_well_known ,
2426
2429
self . inner . event_cache . clone ( ) ,
2427
2430
self . inner . send_queue_data . clone ( ) ,
0 commit comments