use std::fmt::{self, Display, Formatter};
use crate::{filter::Filter, ordering::Ordering, schema::SchemaMapped};
use super::error::QueryResult;
pub mod aes256;
pub mod base64;
pub mod plain;
pub mod rsa;
mod utility;
#[derive(Debug, Clone, PartialEq)]
pub struct FilterPageToken {
pub filter: Filter,
}
impl FilterPageToken {
pub const fn new(filter: Filter) -> Self {
Self { filter }
}
}
pub trait PageTokenBuilder {
type PageToken: Clone + ToString;
fn parse(
&self,
filter: &Filter,
ordering: &Ordering,
salt: &[u8],
page_token: &str,
) -> QueryResult<Self::PageToken>;
fn build_next<T: SchemaMapped>(
&self,
filter: &Filter,
ordering: &Ordering,
salt: &[u8],
next_item: &T,
) -> QueryResult<String>;
}
impl Display for FilterPageToken {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.filter)
}
}