From 2f19e2b762a0dafdb7a1c72c0ca00bf2bf297e8f Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 28 Oct 2024 15:27:23 +0100 Subject: [PATCH] chore(sdk): Rename `event_cache/store.rs` to `event_cache/room/events.rs`. This patch renames the `store.rs` file to `room/events.rs`. --- crates/matrix-sdk/src/event_cache/mod.rs | 4 ++-- crates/matrix-sdk/src/event_cache/pagination.rs | 6 +++--- .../src/event_cache/{store.rs => room/events.rs} | 11 ++--------- crates/matrix-sdk/src/event_cache/room/mod.rs | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 14 deletions(-) rename crates/matrix-sdk/src/event_cache/{store.rs => room/events.rs} (98%) create mode 100644 crates/matrix-sdk/src/event_cache/room/mod.rs diff --git a/crates/matrix-sdk/src/event_cache/mod.rs b/crates/matrix-sdk/src/event_cache/mod.rs index 391c6d710..3d50627ac 100644 --- a/crates/matrix-sdk/src/event_cache/mod.rs +++ b/crates/matrix-sdk/src/event_cache/mod.rs @@ -58,13 +58,13 @@ use tracing::{error, info_span, instrument, trace, warn, Instrument as _, Span}; use self::{ paginator::PaginatorError, - store::{Gap, RoomEvents}, + room::events::{Gap, RoomEvents}, }; use crate::{client::WeakClient, room::WeakRoom, Client}; mod linked_chunk; mod pagination; -mod store; +mod room; pub mod paginator; pub use pagination::{RoomPagination, TimelineHasBeenResetWhilePaginating}; diff --git a/crates/matrix-sdk/src/event_cache/pagination.rs b/crates/matrix-sdk/src/event_cache/pagination.rs index 74e943aae..ce994048c 100644 --- a/crates/matrix-sdk/src/event_cache/pagination.rs +++ b/crates/matrix-sdk/src/event_cache/pagination.rs @@ -22,11 +22,11 @@ use tokio::time::timeout; use tracing::{debug, instrument, trace}; use super::{ + linked_chunk::ChunkContent, paginator::{PaginationResult, PaginatorState}, - store::Gap, + room::events::{Gap, RoomEvents}, BackPaginationOutcome, Result, RoomEventCacheInner, }; -use crate::event_cache::{linked_chunk::ChunkContent, store::RoomEvents}; /// An API object to run pagination queries on a [`super::RoomEventCache`]. /// @@ -321,7 +321,7 @@ mod tests { use tokio::{spawn, time::sleep}; use crate::{ - deserialized_responses::SyncTimelineEvent, event_cache::store::Gap, + deserialized_responses::SyncTimelineEvent, event_cache::room::events::Gap, test_utils::logged_in_client, }; diff --git a/crates/matrix-sdk/src/event_cache/store.rs b/crates/matrix-sdk/src/event_cache/room/events.rs similarity index 98% rename from crates/matrix-sdk/src/event_cache/store.rs rename to crates/matrix-sdk/src/event_cache/room/events.rs index eb7e771db..f1b4eba7a 100644 --- a/crates/matrix-sdk/src/event_cache/store.rs +++ b/crates/matrix-sdk/src/event_cache/room/events.rs @@ -12,11 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::fmt; - use matrix_sdk_common::deserialized_responses::SyncTimelineEvent; -use super::linked_chunk::{Chunk, ChunkIdentifier, Error, Iter, LinkedChunk, Position}; +use super::super::linked_chunk::{Chunk, ChunkIdentifier, Error, Iter, LinkedChunk, Position}; /// An alias for the real event type. pub(crate) type Event = SyncTimelineEvent; @@ -31,6 +29,7 @@ pub struct Gap { const DEFAULT_CHUNK_CAPACITY: usize = 128; /// This type represents all events of a single room. +#[derive(Debug)] pub struct RoomEvents { /// The real in-memory storage for all the events. chunks: LinkedChunk, @@ -132,12 +131,6 @@ impl RoomEvents { } } -impl fmt::Debug for RoomEvents { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - formatter.debug_struct("RoomEvents").field("chunk", &self.chunks).finish() - } -} - #[cfg(test)] mod tests { use assert_matches2::assert_let; diff --git a/crates/matrix-sdk/src/event_cache/room/mod.rs b/crates/matrix-sdk/src/event_cache/room/mod.rs new file mode 100644 index 000000000..0fbadbfee --- /dev/null +++ b/crates/matrix-sdk/src/event_cache/room/mod.rs @@ -0,0 +1,15 @@ +// Copyright 2024 The Matrix.org Foundation C.I.C. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +pub(super) mod events;