Skip to content

Commit c3e28f7

Browse files
committed
refactor: Move linked_chunk from matrix-sdk to matrix-sdk-common.
1 parent 949cd78 commit c3e28f7

File tree

10 files changed

+18
-10
lines changed

10 files changed

+18
-10
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/matrix-sdk-base/src/event_cache/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
//! Event cache store and common types shared with `matrix_sdk::event_cache`.
16+
1517
pub mod store;

crates/matrix-sdk-common/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ uniffi = ["dep:uniffi"]
2121

2222
[dependencies]
2323
async-trait = { workspace = true }
24+
eyeball-im = { workspace = true }
2425
futures-core = { workspace = true }
26+
futures-util = { workspace = true }
27+
imbl = { workspace = true }
2528
ruma = { workspace = true }
2629
serde = { workspace = true }
2730
serde_json = { workspace = true }

crates/matrix-sdk-common/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub mod debug;
2525
pub mod deserialized_responses;
2626
pub mod executor;
2727
pub mod failures_cache;
28+
pub mod linked_chunk;
2829
pub mod ring_buffer;
2930
pub mod store_locks;
3031
pub mod timeout;

crates/matrix-sdk/src/event_cache/linked_chunk/mod.rs renamed to crates/matrix-sdk-common/src/linked_chunk/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
#![allow(dead_code)]
16+
#![allow(rustdoc::private_intra_doc_links)]
1617

1718
//! A linked chunk is the underlying data structure that holds all events.
1819
@@ -56,7 +57,7 @@ macro_rules! assert_items_eq {
5657
let chunk = $iterator .next().expect("next chunk (expect items)");
5758
assert!(chunk.is_items(), "chunk should contain items");
5859

59-
let $crate::event_cache::linked_chunk::ChunkContent::Items(items) = chunk.content() else {
60+
let $crate::linked_chunk::ChunkContent::Items(items) = chunk.content() else {
6061
unreachable!()
6162
};
6263

@@ -934,7 +935,6 @@ impl ChunkIdentifierGenerator {
934935
#[repr(transparent)]
935936
pub struct ChunkIdentifier(u64);
936937

937-
#[cfg(test)]
938938
impl PartialEq<u64> for ChunkIdentifier {
939939
fn eq(&self, other: &u64) -> bool {
940940
self.0 == *other
@@ -963,7 +963,7 @@ impl Position {
963963
/// # Panic
964964
///
965965
/// This method will panic if it will underflow, i.e. if the index is 0.
966-
pub(super) fn decrement_index(&mut self) {
966+
pub fn decrement_index(&mut self) {
967967
self.1 = self.1.checked_sub(1).expect("Cannot decrement the index because it's already 0");
968968
}
969969
}
@@ -1346,7 +1346,8 @@ where
13461346
}
13471347

13481348
/// A type representing what to do when the system has to handle an empty chunk.
1349-
pub(crate) enum EmptyChunk {
1349+
#[derive(Debug)]
1350+
pub enum EmptyChunk {
13501351
/// Keep the empty chunk.
13511352
Keep,
13521353

crates/matrix-sdk/src/event_cache/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ use self::paginator::PaginatorError;
5454
use crate::{client::WeakClient, Client};
5555

5656
mod deduplicator;
57-
mod linked_chunk;
5857
mod pagination;
5958
mod room;
6059

crates/matrix-sdk/src/event_cache/pagination.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ use std::{future::Future, ops::ControlFlow, sync::Arc, time::Duration};
1818

1919
use eyeball::Subscriber;
2020
use matrix_sdk_base::deserialized_responses::SyncTimelineEvent;
21+
use matrix_sdk_common::linked_chunk::ChunkContent;
2122
use tokio::time::timeout;
2223
use tracing::{debug, instrument, trace};
2324

2425
use super::{
25-
linked_chunk::ChunkContent,
2626
paginator::{PaginationResult, PaginatorState},
2727
room::{
2828
events::{Gap, RoomEvents},

crates/matrix-sdk/src/event_cache/room/events.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
use std::cmp::Ordering;
1616

1717
use matrix_sdk_common::deserialized_responses::SyncTimelineEvent;
18+
use matrix_sdk_common::linked_chunk::{
19+
Chunk, ChunkIdentifier, EmptyChunk, Error, Iter, LinkedChunk, Position,
20+
};
1821
use ruma::OwnedEventId;
1922
use tracing::{debug, error, warn};
2023

21-
use super::super::{
22-
deduplicator::{Decoration, Deduplicator},
23-
linked_chunk::{Chunk, ChunkIdentifier, EmptyChunk, Error, Iter, LinkedChunk, Position},
24-
};
24+
use super::super::deduplicator::{Decoration, Deduplicator};
2525

2626
/// An alias for the real event type.
2727
pub(crate) type Event = SyncTimelineEvent;

0 commit comments

Comments
 (0)