172 похожих чатов

Подскажите как получше организовать этот крайне некрасивый кот:

let broadcast_incoming = read
.try_filter_map(|msg| {
let result = match msg {
tokio_tungstenite::tungstenite::Message::Pong(_) => Some(Ok(sqlx::query_file!(
"sql/insert_ping.sql",
IMEI.to_string()
))),
tokio_tungstenite::tungstenite::Message::Binary(bytes) => {
Some(handle_binary_message(&bytes))
}
whatever => {
println!("whatever {:?}", whatever);
None
}
};
future::ok(result)
})
.map(|result| {
result.unwrap().unwrap().execute(pool);
});

1 ответов

21 просмотр
Arseniy-Lebedev Автор вопроса

Я переписал его вот так let handle_incoming = read .map(to_query) .for_each(|result| { // future::ready(()) result.unwrap().execute(pool); future::ready(()) }); Но я не могу понять как превратить из асинхронного result.unwrap().execute(pool); что-то похожее на future::ready(())

Похожие вопросы

Обсуждают сегодня

Скажите, можно ли как-то "переместить" динамический массив из одной переменной в другую? Скажем, переместить из TList<> в TArray<>. Именно переместить, а не скопировать. Если ...
Eugene Krasnikov (ᴊɪɴ x)
37
комрады, че-та лыжы не едут var tmpFont: TFont; begin tmpFont:= TFont.Create; try case rgFontColor.ItemIndex of 0: tmpFont.Color:= clWindowText; 1: tmpFo...
Ed Doc
34
М-да. Почему бы просто со stringlist не работать?
Michael Longneck
22
Is there a digital way to cut the electricity from a usb in linux? It sounds weird, but it's exactly what I need to do. I tried to simulate the unplug/replug but is not the ...
Eduard Rivas
15
Интересно, нет ли какого-то способа получить из dll не адрес самой метки, а адрес со смещением?
The Bird of Hermes
54
generic procedure function test<T>(param: T); type case T of longint: NewT = word; longword: NewT = byte; end; var v1: NewT; Как это можно сделать? Чтобы у меня...
notme
21
Делал задачу вот такую https://stepik.org/lesson/4985/step/9?unit=1083 получилось такое https://play.haskell.org/saved/ipKrepqe оно работает, тестов много не писал, но работае...
Fedor
22
Можно вообще написать: Person fName' lName' age'. Тогда действительно имена полей потребуются лишь в строковом виде, чтобы эти fName' и т.д. достать :-) Но разве для этого нуж...
Михаил
8
Hello everyone I am trying to run 4 year old project and I am having this issue anyone can help?
Nitish Garg
11
Anyone here suffers from unexplained aural migraines, who would be up for talking for a bit? Doesn't *have* to be aural, but I am not asking about headaches, I mean actual mi...
Martin Rys
58
Карта сайта