pub struct Paginator<PR: PaginableRoom> { /* private fields */ }
Expand description
A stateful object to reach to an event, and then paginate backward and forward from it.
See also the module-level documentation.
Implementations§
Source§impl<PR: PaginableRoom> Paginator<PR>
impl<PR: PaginableRoom> Paginator<PR>
Sourcepub fn state(&self) -> Subscriber<PaginatorState>
pub fn state(&self) -> Subscriber<PaginatorState>
Returns a subscriber to the internal PaginatorState
machine.
Sourcepub async fn start_from(
&self,
event_id: &EventId,
num_events: UInt,
) -> Result<StartFromResult, PaginatorError>
pub async fn start_from( &self, event_id: &EventId, num_events: UInt, ) -> Result<StartFromResult, PaginatorError>
Starts the pagination from the initial event, requesting num_events
additional context events.
Only works for fresh Paginator
objects, which are in the
PaginatorState::Initial
state.
Sourcepub async fn paginate_backward(
&self,
num_events: UInt,
) -> Result<PaginationResult, PaginatorError>
pub async fn paginate_backward( &self, num_events: UInt, ) -> Result<PaginationResult, PaginatorError>
Runs a backward pagination (requesting num_events
to the server), from
the current state of the object.
Will return immediately if we have already hit the start of the timeline.
May return an error if it’s already paginating, or if the call to /messages failed.
Sourcepub fn hit_timeline_start(&self) -> bool
pub fn hit_timeline_start(&self) -> bool
Returns whether we’ve hit the start of the timeline.
This is true if, and only if, we didn’t have a previous-batch token and running backwards pagination would be useless.
Sourcepub fn hit_timeline_end(&self) -> bool
pub fn hit_timeline_end(&self) -> bool
Returns whether we’ve hit the end of the timeline.
This is true if, and only if, we didn’t have a next-batch token and running forwards pagination would be useless.
Sourcepub async fn paginate_forward(
&self,
num_events: UInt,
) -> Result<PaginationResult, PaginatorError>
pub async fn paginate_forward( &self, num_events: UInt, ) -> Result<PaginationResult, PaginatorError>
Runs a forward pagination (requesting num_events
to the server), from
the current state of the object.
Will return immediately if we have already hit the end of the timeline.
May return an error if it’s already paginating, or if the call to /messages failed.
Trait Implementations§
Auto Trait Implementations§
impl<PR> !Freeze for Paginator<PR>
impl<PR> RefUnwindSafe for Paginator<PR>where
PR: RefUnwindSafe,
impl<PR> Send for Paginator<PR>
impl<PR> Sync for Paginator<PR>
impl<PR> Unpin for Paginator<PR>where
PR: Unpin,
impl<PR> UnwindSafe for Paginator<PR>where
PR: UnwindSafe,
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