From 9c4318d191cdcdcec22dbae0b1c2f0d1dc148d6a Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 18 Mar 2024 12:21:21 +0100 Subject: [PATCH] feat(sdk): Convert `ChunkIdentifier` to `ItemPosition`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch implements `From` for `ItemPosition`. It's useful when we get a `ChunkIdentifier` and we need to `insert_… _at(item_position)`. --- crates/matrix-sdk/src/event_cache/linked_chunk.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/matrix-sdk/src/event_cache/linked_chunk.rs b/crates/matrix-sdk/src/event_cache/linked_chunk.rs index 029d7c846..e11f38f34 100644 --- a/crates/matrix-sdk/src/event_cache/linked_chunk.rs +++ b/crates/matrix-sdk/src/event_cache/linked_chunk.rs @@ -598,6 +598,12 @@ impl ItemPosition { } } +impl From for ItemPosition { + fn from(chunk_identifier: ChunkIdentifier) -> Self { + Self(chunk_identifier, 0) + } +} + /// An iterator over a [`LinkedChunk`] that traverses the chunk in backward /// direction (i.e. it calls `previous` on each chunk to make progress). pub struct LinkedChunkIterBackward<'a, Item, Gap, const CAP: usize> {