pub struct Pagination<T>{ /* private fields */ }
Expand description
A struct for paginating results
§Example
#[derive(Table, Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct Users {
pub id: PrimaryKeyInteger,
pub username: String,
pub age: i32,
pub postcode: Option<String>,
}
pub type UserPage = Pagination<Users>;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let database = libsql::Builder::new_local(":memory:").build().await?;
let connection = database.connect().unwrap();
// Create a new Page instance
let mut page = UserPage::new();
// Update the page to the next page
let results = page.next(&connection).await?;
}
Implementations§
Source§impl<T> Pagination<T>
impl<T> Pagination<T>
Sourcepub async fn get<'a, C>(&mut self, connection: &'a C) -> Result<Vec<T>, Error>where
C: GeekConnection<Connection = C> + 'a,
pub async fn get<'a, C>(&mut self, connection: &'a C) -> Result<Vec<T>, Error>where
C: GeekConnection<Connection = C> + 'a,
Get the current page results
Trait Implementations§
Source§impl<T> Default for Pagination<T>
impl<T> Default for Pagination<T>
Auto Trait Implementations§
impl<T> Freeze for Pagination<T>
impl<T> RefUnwindSafe for Pagination<T>where
T: RefUnwindSafe,
impl<T> Send for Pagination<T>where
T: Send,
impl<T> Sync for Pagination<T>where
T: Sync,
impl<T> Unpin for Pagination<T>where
T: Unpin,
impl<T> UnwindSafe for Pagination<T>where
T: 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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request