From bf6e4a8d011cd1717ea1fd67b0fdd2731ef02b58 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 9 Oct 2024 17:37:13 +0200 Subject: [PATCH] chore(timeline): add an FFI helper to get the debug string of a `TimelineUniqueId` --- Cargo.lock | 1 + crates/matrix-sdk-ui/Cargo.toml | 1 + crates/matrix-sdk-ui/src/timeline/item.rs | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index f562bfe965a..b082e7b35ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3535,6 +3535,7 @@ dependencies = [ "itertools 0.12.1", "matrix-sdk", "matrix-sdk-base", + "matrix-sdk-ffi-macros", "matrix-sdk-test", "mime", "once_cell", diff --git a/crates/matrix-sdk-ui/Cargo.toml b/crates/matrix-sdk-ui/Cargo.toml index cd1293b6420..0ff034f6efc 100644 --- a/crates/matrix-sdk-ui/Cargo.toml +++ b/crates/matrix-sdk-ui/Cargo.toml @@ -37,6 +37,7 @@ indexmap = "2.0.0" itertools = { workspace = true } matrix-sdk = { workspace = true, features = ["experimental-sliding-sync", "e2e-encryption"] } matrix-sdk-base = { workspace = true } +matrix-sdk-ffi-macros = { workspace = true } mime = "0.3.16" once_cell = { workspace = true } pin-project-lite = { workspace = true } diff --git a/crates/matrix-sdk-ui/src/timeline/item.rs b/crates/matrix-sdk-ui/src/timeline/item.rs index 58e4a84191a..d26776042c5 100644 --- a/crates/matrix-sdk-ui/src/timeline/item.rs +++ b/crates/matrix-sdk-ui/src/timeline/item.rs @@ -27,6 +27,16 @@ use super::{EventTimelineItem, VirtualTimelineItem}; #[cfg_attr(feature = "uniffi", derive(uniffi::Object))] pub struct TimelineUniqueId(pub(crate) String); +#[cfg(all(not(tarpaulin_include), feature = "uniffi"))] // debug-logging functionality +#[matrix_sdk_ffi_macros::export] +impl TimelineUniqueId { + /// Returns a debug string representing the unique id, for debugging + /// purposes. + pub fn debug_string(&self) -> String { + format!("{self:?}") + } +} + impl PartialEq for &TimelineUniqueId { fn eq(&self, other: &TimelineUniqueId) -> bool { self.0 == other.0