From 1b3be248372cf3545baaece986bb303733efac91 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/element.rs | 20 ++++++++++++++++++++ bindings/matrix-sdk-ffi/src/lib.rs | 1 + 2 files changed, 21 insertions(+) create mode 100644 bindings/matrix-sdk-ffi/src/element.rs diff --git a/bindings/matrix-sdk-ffi/src/element.rs b/bindings/matrix-sdk-ffi/src/element.rs new file mode 100644 index 0000000000..b5a5254618 --- /dev/null +++ b/bindings/matrix-sdk-ffi/src/element.rs @@ -0,0 +1,20 @@ +use crate::ClientError; +use serde::Deserialize; + +/// 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 aba6e22596..f475f7e862 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;