From 38a18c3c8e3be2951967d463ade1f6607228e6a7 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 27 Jun 2024 10:03:23 +0300 Subject: [PATCH] feat(ffi): add Element specific well known struct and a way to deserialize it from external clients --- bindings/matrix-sdk-ffi/src/client.rs | 3 ++- bindings/matrix-sdk-ffi/src/element.rs | 21 +++++++++++++++++++++ bindings/matrix-sdk-ffi/src/lib.rs | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 bindings/matrix-sdk-ffi/src/element.rs diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index f444429580c..633c18912b9 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -421,7 +421,8 @@ impl Client { }))) } - /// Allows generic GET requests to be made through the SDKs internal HTTP client + /// Allows generic GET requests to be made through the SDKs internal HTTP + /// client pub async fn get_url(&self, url: String) -> Result { let http_client = self.inner.http_client(); Ok(http_client.get(url).send().await?.text().await?) diff --git a/bindings/matrix-sdk-ffi/src/element.rs b/bindings/matrix-sdk-ffi/src/element.rs new file mode 100644 index 00000000000..3d9c81b9710 --- /dev/null +++ b/bindings/matrix-sdk-ffi/src/element.rs @@ -0,0 +1,21 @@ +use serde::Deserialize; + +use crate::ClientError; + +/// Well-known settings specific to ElementCall +#[derive(Deserialize, uniffi::Record)] +pub struct ElementCallWellKnown { + widget_url: String, +} + +/// Element specific well-known settings +#[derive(Deserialize, uniffi::Record)] +pub struct ElementWellKnown { + call: ElementCallWellKnown, +} + +/// Helper function to parse a string into a ElementWellKnown struct +#[uniffi::export] +pub fn make_element_well_known(string: String) -> Result { + serde_json::from_str(&string).map_err(ClientError::new) +} diff --git a/bindings/matrix-sdk-ffi/src/lib.rs b/bindings/matrix-sdk-ffi/src/lib.rs index aba6e22596e..f475f7e862d 100644 --- a/bindings/matrix-sdk-ffi/src/lib.rs +++ b/bindings/matrix-sdk-ffi/src/lib.rs @@ -24,6 +24,7 @@ mod authentication; mod chunk_iterator; mod client; mod client_builder; +mod element; mod encryption; mod error; mod event;