pub trait LoadExt {
// Provided methods
fn load<'e, Idx, E: PgExecutor<'e>>(
&self,
executor: E,
) -> impl Future<Output = Result<Vec<<Self as RowQuery<Idx>>::Output>>>
where Self: RowQuery<Idx> { ... }
fn load_one<'e, Idx, E: PgExecutor<'e>>(
&self,
executor: E,
) -> impl Future<Output = Result<Option<<Self as RowQuery<Idx>>::Output>>>
where Self: RowQuery<Idx> { ... }
fn stream<'e, Idx, E: PgExecutor<'e>>(
&self,
executor: E,
) -> Result<impl Stream<Item = Result<<Self as RowQuery<Idx>>::Output>> + Send + Unpin + 'e>
where Self: RowQuery<Idx>,
<Self as RowQuery<Idx>>::Output: Send + 'e { ... }
}Expand description
load for the rows, load_one for the first of them, stream for
them one at a time, and ExecuteExt::execute where there are none to
decode. One trait for
every row-producing builder keeps the terminal vocabulary tied to what a
statement yields rather than to which builder happens to be in hand.
Implemented for every builder, satisfiable by the ones that produce
rows: what a builder can’t do is then reported by RowQuery, which says
so, rather than by the method not existing — which rustc answers with a
list of unsatisfied bounds or, worse, by suggesting Iterator. Not a
blanket impl, since load/count/execute are names other traits in a
caller’s scope have too. A builder added here needs its three empty
impls, or its terminal goes back to reporting nothing.
Provided Methods§
fn load<'e, Idx, E: PgExecutor<'e>>(
&self,
executor: E,
) -> impl Future<Output = Result<Vec<<Self as RowQuery<Idx>>::Output>>>where
Self: RowQuery<Idx>,
fn load_one<'e, Idx, E: PgExecutor<'e>>(
&self,
executor: E,
) -> impl Future<Output = Result<Option<<Self as RowQuery<Idx>>::Output>>>where
Self: RowQuery<Idx>,
Sourcefn stream<'e, Idx, E: PgExecutor<'e>>(
&self,
executor: E,
) -> Result<impl Stream<Item = Result<<Self as RowQuery<Idx>>::Output>> + Send + Unpin + 'e>
fn stream<'e, Idx, E: PgExecutor<'e>>( &self, executor: E, ) -> Result<impl Stream<Item = Result<<Self as RowQuery<Idx>>::Output>> + Send + Unpin + 'e>
The rows one at a time, for a result too large to hold: an export
that writes as it reads rather than collecting first. Yields the
same values .load(..) would, decoded as each row arrives.
Not a cursor: the server still produces the whole result, and the
connection is held until the stream is dropped or exhausted. What
this bounds is the client’s memory, which is what a Vec of every
row costs.
Returns a Result around the stream rather than as its first item,
because what can fail before a row arrives — an unresolved
placeholder, a value whose feature is on in qbrs and off here —
is a misuse of this crate rather than a row that didn’t decode.
Everything the database has to say arrives as an item.
Send and Unpin are promised, so the stream can be spawned and
polled without pinning it first — a generic caller cannot ask for
either otherwise.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".