refactor(sdk): move search related functions to a message_search module

This commit is contained in:
Benjamin Bouvier
2026-04-17 10:45:26 +02:00
parent e54a36a1ca
commit 3789374951
3 changed files with 38 additions and 19 deletions
+3
View File
@@ -63,6 +63,9 @@ pub mod sync;
#[cfg(feature = "experimental-widgets")]
pub mod widget;
#[cfg(feature = "experimental-search")]
mod message_search;;
pub use account::Account;
pub use authentication::{AuthApi, AuthSession, SessionTokens};
pub use client::homeserver_capabilities::HomeserverCapabilities;
+34
View File
@@ -0,0 +1,34 @@
// Copyright 2026 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.
use matrix_sdk_search::error::IndexError;
#[cfg(doc)]
use matrix_sdk_search::index::RoomIndex;
use ruma::OwnedEventId;
use crate::Room;
impl Room {
/// Search this room's [`RoomIndex`] for query and return at most
/// max_number_of_results results.
pub async fn search(
&self,
query: &str,
max_number_of_results: usize,
pagination_offset: Option<usize>,
) -> Result<Vec<OwnedEventId>, IndexError> {
let mut search_index_guard = self.client.search_index().lock().await;
search_index_guard.search(query, max_number_of_results, pagination_offset, self.room_id())
}
}
+1 -19
View File
@@ -58,14 +58,9 @@ use matrix_sdk_common::{
executor::{JoinHandle, spawn},
timeout::timeout,
};
#[cfg(feature = "experimental-search")]
use matrix_sdk_search::error::IndexError;
#[cfg(feature = "experimental-search")]
#[cfg(doc)]
use matrix_sdk_search::index::RoomIndex;
use mime::Mime;
use reply::Reply;
#[cfg(any(feature = "experimental-search", feature = "e2e-encryption"))]
#[cfg(feature = "e2e-encryption")]
use ruma::events::AnySyncMessageLikeEvent;
#[cfg(feature = "experimental-encrypted-state-events")]
use ruma::events::AnySyncStateEvent;
@@ -4285,19 +4280,6 @@ impl Room {
relations
}
/// Search this room's [`RoomIndex`] for query and return at most
/// max_number_of_results results.
#[cfg(feature = "experimental-search")]
pub async fn search(
&self,
query: &str,
max_number_of_results: usize,
pagination_offset: Option<usize>,
) -> Result<Vec<OwnedEventId>, IndexError> {
let mut search_index_guard = self.client.search_index().lock().await;
search_index_guard.search(query, max_number_of_results, pagination_offset, self.room_id())
}
/// Subscribe to a given thread in this room.
///
/// This will subscribe the user to the thread, so that they will receive