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, None).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,
via_server: Option<OwnedServerName>,
) -> Result<()>
pub async fn search( &mut self, filter: Option<String>, batch_size: u32, via_server: Option<OwnedServerName>, ) -> 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.
If the via_server
is not provided it will search in the current
homeserver by default.
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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