pub struct QueryStream<T> { /* private fields */ }Expand description
Query builder for streaming results
This is a lightweight wrapper that helps construct streaming queries. It doesn’t implement Stream itself to avoid lifetime issues.
Implementations§
Source§impl<T> QueryStream<T>where
T: Send + 'static,
impl<T> QueryStream<T>where
T: Send + 'static,
Sourcepub fn new(pool: &PgPool, query: impl Into<String>) -> Self
pub fn new(pool: &PgPool, query: impl Into<String>) -> Self
Create a new query stream builder
The pool is cloned (cheap operation as PgPool uses Arc internally)
Sourcepub async fn collect_vec(self) -> Result<Vec<T>>
pub async fn collect_vec(self) -> Result<Vec<T>>
Execute the query and collect all results into a Vec
This is the recommended method for most use cases.
Auto Trait Implementations§
impl<T> Freeze for QueryStream<T>
impl<T> !RefUnwindSafe for QueryStream<T>
impl<T> Send for QueryStream<T>where
T: Send,
impl<T> Sync for QueryStream<T>where
T: Sync,
impl<T> Unpin for QueryStream<T>where
T: Unpin,
impl<T> !UnwindSafe for QueryStream<T>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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