From 9eee20b4f0cf71dfc507d20f65942d9ff043544f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Tue, 2 Dec 2025 15:24:55 +0100 Subject: [PATCH] feat(ffi): add bindings for `Client::get_store_sizes` --- bindings/matrix-sdk-ffi/src/client.rs | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 70c24a21a..2aeacea98 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -365,6 +365,11 @@ impl Client { Ok(self.inner.optimize_stores().await?) } + /// Returns the sizes of the existing stores, if known. + pub async fn get_store_sizes(&self) -> Result { + Ok(self.inner.get_store_sizes().await?.into()) + } + /// Information about login options for the client's homeserver. pub async fn homeserver_login_details(&self) -> Arc { let oauth = self.inner.oauth(); @@ -2857,3 +2862,28 @@ impl TryFrom for AllowRule { } } } + +/// Contains the disk size of the different stores, if known. It won't be +/// available for in-memory stores. +#[derive(Debug, Clone, uniffi::Record)] +pub struct StoreSizes { + /// The size of the CryptoStore. + crypto_store: Option, + /// The size of the StateStore. + state_store: Option, + /// The size of the EventCacheStore. + event_cache_store: Option, + /// The size of the MediaStore. + media_store: Option, +} + +impl From for StoreSizes { + fn from(value: matrix_sdk::StoreSizes) -> Self { + Self { + crypto_store: value.crypto_store.map(|v| v as u64), + state_store: value.state_store.map(|v| v as u64), + event_cache_store: value.event_cache_store.map(|v| v as u64), + media_store: value.media_store.map(|v| v as u64), + } + } +}