Skip to content

Commit 9eee20b

Browse files
committed
feat(ffi): add bindings for Client::get_store_sizes
1 parent bc45457 commit 9eee20b

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ impl Client {
365365
Ok(self.inner.optimize_stores().await?)
366366
}
367367

368+
/// Returns the sizes of the existing stores, if known.
369+
pub async fn get_store_sizes(&self) -> Result<StoreSizes, ClientError> {
370+
Ok(self.inner.get_store_sizes().await?.into())
371+
}
372+
368373
/// Information about login options for the client's homeserver.
369374
pub async fn homeserver_login_details(&self) -> Arc<HomeserverLoginDetails> {
370375
let oauth = self.inner.oauth();
@@ -2857,3 +2862,28 @@ impl TryFrom<RumaAllowRule> for AllowRule {
28572862
}
28582863
}
28592864
}
2865+
2866+
/// Contains the disk size of the different stores, if known. It won't be
2867+
/// available for in-memory stores.
2868+
#[derive(Debug, Clone, uniffi::Record)]
2869+
pub struct StoreSizes {
2870+
/// The size of the CryptoStore.
2871+
crypto_store: Option<u64>,
2872+
/// The size of the StateStore.
2873+
state_store: Option<u64>,
2874+
/// The size of the EventCacheStore.
2875+
event_cache_store: Option<u64>,
2876+
/// The size of the MediaStore.
2877+
media_store: Option<u64>,
2878+
}
2879+
2880+
impl From<matrix_sdk::StoreSizes> for StoreSizes {
2881+
fn from(value: matrix_sdk::StoreSizes) -> Self {
2882+
Self {
2883+
crypto_store: value.crypto_store.map(|v| v as u64),
2884+
state_store: value.state_store.map(|v| v as u64),
2885+
event_cache_store: value.event_cache_store.map(|v| v as u64),
2886+
media_store: value.media_store.map(|v| v as u64),
2887+
}
2888+
}
2889+
}

0 commit comments

Comments
 (0)