pub trait StreamTrait {
type Stream<'a>: Iterator<Item = Result<QueryResult, DbErr>>
where Self: 'a;
// Required methods
fn get_database_backend(&self) -> DbBackend;
fn stream_raw<'a>(
&'a self,
stmt: Statement,
) -> Result<Self::Stream<'a>, DbErr>;
// Provided method
fn stream<'a, S: StatementBuilder>(
&'a self,
stmt: &S,
) -> Result<Self::Stream<'a>, DbErr> { ... }
}Available on crate feature
stream only.Expand description
Streaming counterpart to ConnectionTrait: yields query results row by
row rather than collecting them all into a Vec. Use this for large
result sets when you don’t want to load everything into memory at once.
Required Associated Types§
Sourcetype Stream<'a>: Iterator<Item = Result<QueryResult, DbErr>>
where
Self: 'a
type Stream<'a>: Iterator<Item = Result<QueryResult, DbErr>> where Self: 'a
Create a stream for the QueryResult
Required Methods§
Sourcefn get_database_backend(&self) -> DbBackend
fn get_database_backend(&self) -> DbBackend
Get the database backend for the connection. This depends on feature flags enabled.
Provided Methods§
Sourcefn stream<'a, S: StatementBuilder>(
&'a self,
stmt: &S,
) -> Result<Self::Stream<'a>, DbErr>
fn stream<'a, S: StatementBuilder>( &'a self, stmt: &S, ) -> Result<Self::Stream<'a>, DbErr>
Execute a StatementBuilder and return a stream of results
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".