From 64698eaf1a570163bb8f776df3eb5b7d5f5dc36e Mon Sep 17 00:00:00 2001 From: Michael Goldenberg Date: Thu, 14 Aug 2025 10:04:06 -0400 Subject: [PATCH] feat(linked chunk): add trait-based conversions between owned and borrowed linked chunk id Signed-off-by: Michael Goldenberg --- crates/matrix-sdk-common/src/linked_chunk/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/matrix-sdk-common/src/linked_chunk/mod.rs b/crates/matrix-sdk-common/src/linked_chunk/mod.rs index 4c7d60713..9df230ee5 100644 --- a/crates/matrix-sdk-common/src/linked_chunk/mod.rs +++ b/crates/matrix-sdk-common/src/linked_chunk/mod.rs @@ -134,6 +134,12 @@ impl LinkedChunkId<'_> { } } +impl<'a> From<&'a OwnedLinkedChunkId> for LinkedChunkId<'a> { + fn from(value: &'a OwnedLinkedChunkId) -> Self { + value.as_ref() + } +} + impl PartialEq<&OwnedLinkedChunkId> for LinkedChunkId<'_> { fn eq(&self, other: &&OwnedLinkedChunkId) -> bool { match (self, other) { @@ -189,6 +195,12 @@ impl OwnedLinkedChunkId { } } +impl From> for OwnedLinkedChunkId { + fn from(value: LinkedChunkId<'_>) -> Self { + value.to_owned() + } +} + /// Errors of [`LinkedChunk`]. #[derive(thiserror::Error, Debug)] pub enum Error {