Skip to content

Commit

Permalink
refactor: Move linked_chunk from matrix-sdk to matrix-sdk-common.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Nov 13, 2024
1 parent a82ac51 commit f9cea99
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/matrix-sdk-base/src/event_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Event cache store and common types shared with `matrix_sdk::event_cache`.
pub mod store;
3 changes: 3 additions & 0 deletions crates/matrix-sdk-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ uniffi = ["dep:uniffi"]

[dependencies]
async-trait = { workspace = true }
eyeball-im = { workspace = true }
futures-core = { workspace = true }
futures-util = { workspace = true }
imbl = { workspace = true }
ruma = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions crates/matrix-sdk-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub mod debug;
pub mod deserialized_responses;
pub mod executor;
pub mod failures_cache;
pub mod linked_chunk;
pub mod ring_buffer;
pub mod store_locks;
pub mod timeout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ macro_rules! assert_items_eq {
let chunk = $iterator .next().expect("next chunk (expect items)");
assert!(chunk.is_items(), "chunk should contain items");

let $crate::event_cache::linked_chunk::ChunkContent::Items(items) = chunk.content() else {
let $crate::linked_chunk::ChunkContent::Items(items) = chunk.content() else {
unreachable!()
};

Expand Down Expand Up @@ -934,7 +934,6 @@ impl ChunkIdentifierGenerator {
#[repr(transparent)]
pub struct ChunkIdentifier(u64);

#[cfg(test)]
impl PartialEq<u64> for ChunkIdentifier {
fn eq(&self, other: &u64) -> bool {
self.0 == *other
Expand Down Expand Up @@ -963,7 +962,7 @@ impl Position {
/// # Panic
///
/// This method will panic if it will underflow, i.e. if the index is 0.
pub(super) fn decrement_index(&mut self) {
pub fn decrement_index(&mut self) {
self.1 = self.1.checked_sub(1).expect("Cannot decrement the index because it's already 0");
}
}
Expand Down Expand Up @@ -1346,7 +1345,8 @@ where
}

/// A type representing what to do when the system has to handle an empty chunk.
pub(crate) enum EmptyChunk {
#[derive(Debug)]
pub enum EmptyChunk {
/// Keep the empty chunk.
Keep,

Expand Down
1 change: 0 additions & 1 deletion crates/matrix-sdk/src/event_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ use self::paginator::PaginatorError;
use crate::{client::WeakClient, Client};

mod deduplicator;
mod linked_chunk;
mod pagination;
mod room;

Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk/src/event_cache/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use std::{future::Future, ops::ControlFlow, sync::Arc, time::Duration};

use eyeball::Subscriber;
use matrix_sdk_base::deserialized_responses::SyncTimelineEvent;
use matrix_sdk_common::linked_chunk::ChunkContent;
use tokio::time::timeout;
use tracing::{debug, instrument, trace};

use super::{
linked_chunk::ChunkContent,
paginator::{PaginationResult, PaginatorState},
room::{
events::{Gap, RoomEvents},
Expand Down
8 changes: 4 additions & 4 deletions crates/matrix-sdk/src/event_cache/room/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
use std::cmp::Ordering;

use matrix_sdk_common::deserialized_responses::SyncTimelineEvent;
use matrix_sdk_common::linked_chunk::{
Chunk, ChunkIdentifier, EmptyChunk, Error, Iter, LinkedChunk, Position,
};
use ruma::OwnedEventId;
use tracing::{debug, error, warn};

use super::super::{
deduplicator::{Decoration, Deduplicator},
linked_chunk::{Chunk, ChunkIdentifier, EmptyChunk, Error, Iter, LinkedChunk, Position},
};
use super::super::deduplicator::{Decoration, Deduplicator};

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

0 comments on commit f9cea99

Please sign in to comment.