mod room;
pub mod thread;
use std::sync::Arc;
use matrix_sdk_base::deserialized_responses::TimelineEvent;
pub use room::*;
use ruma::OwnedEventId;
#[derive(Clone, Debug, PartialEq)]
pub enum PaginationToken {
None,
HasMore(String),
HitEnd,
}
impl PaginationToken {
pub fn into_token(self) -> Option<String> {
match self {
Self::HasMore(token) => Some(token),
Self::None | Self::HitEnd => None,
}
}
}
impl From<Option<String>> for PaginationToken {
fn from(token: Option<String>) -> Self {
match token {
Some(val) => Self::HasMore(val),
None => Self::None,
}
}
}
#[derive(Debug)]
pub struct PaginationResult {
pub events: Vec<TimelineEvent>,
pub hit_end_of_timeline: bool,
}
#[derive(Clone, Debug, thiserror::Error)]
pub enum PaginatorError {
#[error("target event with id {0} could not be found")]
EventNotFound(OwnedEventId),
#[error("expected paginator state {expected:?}, observed {actual:?}")]
InvalidPreviousState {
expected: PaginatorState,
actual: PaginatorState,
},
#[error("an error happened while paginating: {0}")]
SdkError(#[from] Arc<crate::Error>),
}