Available on crate feature
experimental-search only.Expand description
Messages search facilities and high-level helpers to perform searches across one or multiple rooms, with pagination support.
§Examples
§Searching within a single room
Use Room::search_messages to obtain a RoomSearchIterator and call
RoomSearchIterator::next to paginate through event IDs, or
RoomSearchIterator::next_events to load the full TimelineEvents.
let mut iter = room.search_messages("hello world".to_owned(), 10);
while let Some(event_ids) = iter.next().await? {
for event_id in event_ids {
println!("Found event: {event_id}");
}
}§Searching across all joined rooms
Use Client::search_messages to create a GlobalSearchBuilder.
Optionally restrict the working set to DM rooms (or non-DM rooms) before
calling GlobalSearchBuilder::build to get a GlobalSearchIterator.
Use GlobalSearchIterator::next_events to load full TimelineEvents
instead of plain event IDs.
// Search only in DM rooms.
let mut iter = client
.search_messages("hello world".to_owned(), 10)
.only_dm_rooms()
.await?
.build();
while let Some(results) = iter.next_events().await? {
for (room_id, event) in results {
println!(
"Found event in room {room_id} with timestamp: {:?}",
event.timestamp
);
}
}Structs§
- Global
Search Builder - A builder for a
GlobalSearchIteratorthat allows to configure the initial working set of rooms to search in. - Global
Search Iterator - An async iterator for a search query across multiple rooms.
- Room
Search Iterator - An async iterator for a search query in a single room.
Enums§
- Search
Error - An error that can occur while searching messages, using the high-level search helpers provided by this module provided by this module.