Skip to content

Commit 38a18c3

Browse files
stefanceriupoljar
authored andcommitted
feat(ffi): add Element specific well known struct and a way to deserialize it from external clients
1 parent 70fddc0 commit 38a18c3

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ impl Client {
421421
})))
422422
}
423423

424-
/// Allows generic GET requests to be made through the SDKs internal HTTP client
424+
/// Allows generic GET requests to be made through the SDKs internal HTTP
425+
/// client
425426
pub async fn get_url(&self, url: String) -> Result<String, ClientError> {
426427
let http_client = self.inner.http_client();
427428
Ok(http_client.get(url).send().await?.text().await?)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use serde::Deserialize;
2+
3+
use crate::ClientError;
4+
5+
/// Well-known settings specific to ElementCall
6+
#[derive(Deserialize, uniffi::Record)]
7+
pub struct ElementCallWellKnown {
8+
widget_url: String,
9+
}
10+
11+
/// Element specific well-known settings
12+
#[derive(Deserialize, uniffi::Record)]
13+
pub struct ElementWellKnown {
14+
call: ElementCallWellKnown,
15+
}
16+
17+
/// Helper function to parse a string into a ElementWellKnown struct
18+
#[uniffi::export]
19+
pub fn make_element_well_known(string: String) -> Result<ElementWellKnown, ClientError> {
20+
serde_json::from_str(&string).map_err(ClientError::new)
21+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ mod authentication;
2424
mod chunk_iterator;
2525
mod client;
2626
mod client_builder;
27+
mod element;
2728
mod encryption;
2829
mod error;
2930
mod event;

0 commit comments

Comments
 (0)