Skip to main content

arminius_lib_sync/syncv4/execute/fetch/
mod.rs

1// SPDX-FileCopyrightText: 2026 BWI GmbH
2//
3// SPDX-License-Identifier: Apache-2.0
4
5//! Contains logic to fetch data and produce a [Fetched].
6
7mod rooms;
8
9use std::collections::BTreeMap;
10
11use arminius_lib_db_sync::syncv4::TransactedSyncV4Queries;
12use ruma::{OwnedRoomId, api::client::sync::sync_events};
13
14use crate::syncv4::{error::SyncV4Error, plan};
15
16// TODO: `mod extensions;`
17
18/// All the data fetched to produce a sync v4 response.
19pub(super) struct Fetched {
20	/// The actual rooms of a response.
21	pub(crate) rooms: BTreeMap<OwnedRoomId, sync_events::v5::response::Room>,
22	// TODO: `extensions: sync_events::v5::response::Extensions`
23}
24
25/// Fetches all the data for a sync v4 response.
26pub(super) async fn fetch<T: TransactedSyncV4Queries>(
27	transaction: &mut T,
28	plan: &plan::SyncV4Plan,
29) -> Result<Fetched, SyncV4Error> {
30	let rooms = rooms::fetch_rooms(
31		transaction,
32		&plan.connection,
33		&plan.rooms_bump_stamps,
34		&plan.rooms_to_sync,
35	)
36	.await?;
37
38	// TODO: `extensions::fetch_extensions(...).await?;`
39
40	Ok(Fetched { rooms })
41}