Skip to content

Commit

Permalink
feat(ffi): Add Client::available_sliding_sync_versions.
Browse files Browse the repository at this point in the history
This patch adds bindings to `Client::available_sliding_sync_versions`
to `matrix-sdk-ffi`.

This patch also moves `Client::sliding_sync_version` from “private” to
“public” FFI API, in thee sense that this method is now exported with
UniFFI.
  • Loading branch information
Hywan committed Aug 27, 2024
1 parent 5eff9fa commit a413bff
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions bindings/matrix-sdk-ffi/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,6 @@ impl Client {
Ok(())
}

/// The sliding sync version.
pub fn sliding_sync_version(&self) -> SlidingSyncVersion {
self.inner.sliding_sync_version().into()
}

/// Whether or not the client's homeserver supports the password login flow.
pub(crate) async fn supports_password_login(&self) -> anyhow::Result<bool> {
let login_types = self.inner.matrix_auth().get_login_types().await?;
Expand All @@ -478,6 +473,22 @@ impl Client {

#[uniffi::export(async_runtime = "tokio")]
impl Client {
/// The sliding sync version.
pub fn sliding_sync_version(&self) -> SlidingSyncVersion {
self.inner.sliding_sync_version().into()
}

/// Find all sliding sync versions that are available.
///
/// Be careful: This method may hit the store and will send new requests for
/// each call. It can be costly to call it repeatedly.
///
/// If `.well-known` or `/versions` is unreachable, it will simply move
/// potential sliding sync versions aside. No error will be reported.
pub async fn available_sliding_sync_versions(&self) -> Vec<SlidingSyncVersion> {
self.inner.available_sliding_sync_versions().await.into_iter().map(Into::into).collect()
}

pub fn set_delegate(
self: Arc<Self>,
delegate: Option<Box<dyn ClientDelegate>>,
Expand Down

0 comments on commit a413bff

Please sign in to comment.