mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-01-19 23:26:32 +00:00
38 lines
1.0 KiB
Rust
38 lines
1.0 KiB
Rust
use super::{PgRawConnection, PgRow};
|
|
use crate::pg::protocol::Message;
|
|
use futures_core::stream::Stream;
|
|
use std::io;
|
|
|
|
pub fn fetch<'a>(
|
|
conn: &'a mut PgRawConnection,
|
|
) -> impl Stream<Item = Result<PgRow, io::Error>> + 'a {
|
|
async_stream::try_stream! {
|
|
conn.flush().await?;
|
|
|
|
while let Some(message) = conn.receive().await? {
|
|
match message {
|
|
Message::BindComplete
|
|
| Message::ParseComplete
|
|
| Message::PortalSuspended
|
|
| Message::CloseComplete
|
|
| Message::CommandComplete(_) => {}
|
|
|
|
Message::DataRow(body) => {
|
|
yield PgRow(body);
|
|
}
|
|
|
|
Message::ReadyForQuery(_) => {
|
|
return;
|
|
}
|
|
|
|
message => {
|
|
unimplemented!("received {:?} unimplemented message", message);
|
|
}
|
|
}
|
|
}
|
|
|
|
// FIXME: This is an end-of-file error. How we should bubble this up here?
|
|
unreachable!()
|
|
}
|
|
}
|