pub struct RoomDirectorySearch { /* private fields */ }
Expand description
RoomDirectorySearch
allows searching the public room directory, with the
capability of using a filter and a batch_size. This struct is also
responsible for keeping the current state of the search, and exposing an
update of stream of the results, reset the search, or ask for the next page.
⚠️ Users must take great care when using the public room search since the results might contains NSFW content.
§Example
use matrix_sdk::{room_directory_search::RoomDirectorySearch, Client};
use url::Url;
async {
let homeserver = Url::parse("http://localhost:8080")?;
let client = Client::new(homeserver).await?;
let mut room_directory_search = RoomDirectorySearch::new(client);
room_directory_search.search(None, 10).await?;
let (results, mut stream) = room_directory_search.results();
room_directory_search.next_page().await?;
anyhow::Ok(())
};
Implementations§
source§impl RoomDirectorySearch
impl RoomDirectorySearch
sourcepub async fn search(
&mut self,
filter: Option<String>,
batch_size: u32,
) -> Result<()>
pub async fn search( &mut self, filter: Option<String>, batch_size: u32, ) -> Result<()>
Starts a filtered search for the server.
If the filter
is not provided it will search for all the rooms.
You can specify a `batch_size`` to control the number of rooms to fetch
per request.
This method will clear the current search results and start a new one.
sourcepub async fn next_page(&mut self) -> Result<()>
pub async fn next_page(&mut self) -> Result<()>
Asks the server for the next page of the current search.
sourcepub fn results(
&self,
) -> (Vector<RoomDescription>, impl Stream<Item = Vec<VectorDiff<RoomDescription>>>)
pub fn results( &self, ) -> (Vector<RoomDescription>, impl Stream<Item = Vec<VectorDiff<RoomDescription>>>)
Get the initial values of the current stored room descriptions in the search, and a stream of updates for them.
sourcepub fn loaded_pages(&self) -> usize
pub fn loaded_pages(&self) -> usize
Get the number of pages that have been loaded so far.
sourcepub fn is_at_last_page(&self) -> bool
pub fn is_at_last_page(&self) -> bool
Get whether the search is at the last page
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RoomDirectorySearch
impl !RefUnwindSafe for RoomDirectorySearch
impl Send for RoomDirectorySearch
impl Sync for RoomDirectorySearch
impl Unpin for RoomDirectorySearch
impl !UnwindSafe for RoomDirectorySearch
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more