use crate::Cursor;
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct PageRequest<CursorType>
where
CursorType: Cursor,
{
pub first: Option<i32>,
pub before: Option<CursorType>,
pub after: Option<CursorType>,
}
impl<CursorT> PageRequest<CursorT>
where
CursorT: Cursor,
{
pub fn new(first: Option<i32>, after: Option<CursorT>, before: Option<CursorT>) -> Self {
PageRequest {
first,
before,
after,
}
}
pub fn current_cursor(&self) -> Option<CursorT> {
match &self.after {
Some(after) => Some(after.clone()),
None => self.before.clone(),
}
}
}