Skip to content

Commit

Permalink
feat(ffi): add Element specific well known struct and a way to deseri…
Browse files Browse the repository at this point in the history
…alize it from external clients
  • Loading branch information
stefanceriu authored and poljar committed Jun 28, 2024
1 parent 70fddc0 commit 38a18c3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bindings/matrix-sdk-ffi/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, ClientError> {
let http_client = self.inner.http_client();
Ok(http_client.get(url).send().await?.text().await?)
Expand Down
21 changes: 21 additions & 0 deletions bindings/matrix-sdk-ffi/src/element.rs
Original file line number Diff line number Diff line change
@@ -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<ElementWellKnown, ClientError> {
serde_json::from_str(&string).map_err(ClientError::new)
}
1 change: 1 addition & 0 deletions bindings/matrix-sdk-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod authentication;
mod chunk_iterator;
mod client;
mod client_builder;
mod element;
mod encryption;
mod error;
mod event;
Expand Down

0 comments on commit 38a18c3

Please sign in to comment.