Skip to main content

SnapshotPager

Struct SnapshotPager 

Source
pub struct SnapshotPager { /* private fields */ }
Expand description

A bounded, finite read over one PostgreSQL repeatable-read snapshot.

The pager owns the connection-bound transaction. It does not accept an arbitrary executor and never releases the transaction between pages. A pager is intentionally not a stream: callers choose explicit page bounds and must finish or roll back the read transaction.

The pager is deliberately not Send: the snapshot and its connection must stay with the executor that created them.

use dovecote_sqlx_postgres::SnapshotPager;

fn requires_send<T: Send>() {}

fn main() {
    requires_send::<SnapshotPager>();
}

Implementations§

Source§

impl SnapshotPager

Source

pub const fn cursor(&self) -> Option<RowId>

Returns the last row ID returned by a non-empty page.

Source

pub const fn upper_bound(&self) -> Option<RowId>

Returns the maximum row ID visible to this pager’s finite export.

Source

pub const fn is_exhausted(&self) -> bool

Returns whether the pager has returned its final page.

Source

pub async fn next_page( &mut self, limit: Limit, ) -> Result<Vec<PagedEvent>, PageError>

Reads the next bounded page from the retained snapshot.

An empty page marks the pager exhausted and does not advance its cursor. Once exhausted, subsequent calls return an empty page without issuing SQL; call finish or rollback to release the transaction explicitly.

Source

pub async fn finish(self) -> Result<(), PageError>

Commits the read-only transaction and releases its pooled connection.

Source

pub async fn rollback(self) -> Result<(), PageError>

Rolls back the read-only transaction and releases its pooled connection.

Source

pub async fn close(self) -> Result<(), PageError>

Closes the pager by rolling back its read-only transaction.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more