D
Size: a a a
D
A
D
D
A
A
D
let handle = tokio::spawn(async move {
bot.launch().await.expect("bot failed");
});
handle.await;A
D
VC
let stream =
sqlx::query("SELECT content FROM trade WHERE created_at >= $1 AND created_at < $2 ORDER BY id")
.bind(begin)
.bind(end)
.fetch(&pool);
trade_streaming(stream).await;
async fn trade_streaming(mut stream: BoxStream<Result<PgRow, Error>>) -> tokio::task::JoinHandle<()> {
tokio::spawn(async move {
while let Some(row) = stream.try_next().await.unwrap() {
// что-то читаем из row
}
})
}error[E0726]: implicit elided lifetime not allowed here
--> pr/src/db/reading.rs:42:38
|
42 | async fn trade_streaming(mut stream: BoxStream<Result<PgRow, Error>>) -> tokio::task::JoinHandle<()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime: `BoxStream<'_, Result<PgRow, Error>>`
AV
VC
AV
VC
error[E0759]: `stream` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
--> pr/src/db/reading.rs:42:26
|
42 | async fn trade_streaming(mut stream: BoxStream<'_, Result<PgRow, Error>>) -> tokio::task::JoinHandle<()> {
| ^^^^^^^^^^ ----------------------------------- this data with an anonymous lifetime `'_`...
| |
| ...is captured here...
43 | tokio::spawn(async move {
| ------------ ...and is required to live as long as `'static` here
VC
VC
VC
let conn = pool.try_acquire().unwrap();
trade_streaming(conn, date).await;
async fn trade_streaming(mut conn: PoolConnection<Postgres>, date: NaiveDate) -> tokio::task::JoinHandle<()> {
tokio::spawn(async move {
let begin = date.and_hms(0, 0, 0);
let end = begin.add(Duration::days(1));
let mut stream =
sqlx::query("SELECT content FROM trade WHERE created_at >= $1 AND created_at < $2 ORDER BY id")
.bind(begin)
.bind(end)
.fetch(&mut conn);
while let Some(row) = stream.try_next().await.unwrap() {
// ...
}
})
}
VC
VC