Rename iced_sentinel to iced_beacon and refactor its API

This commit is contained in:
Héctor Ramón Jiménez 2024-05-10 20:08:09 +02:00
parent aaf396256e
commit 57033dc4d0
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
19 changed files with 596 additions and 438 deletions

15
beacon/src/stream.rs Normal file
View file

@ -0,0 +1,15 @@
use futures::channel::mpsc;
use futures::stream::{self, Stream, StreamExt};
use futures::Future;
pub fn channel<T, F>(f: impl Fn(mpsc::Sender<T>) -> F) -> impl Stream<Item = T>
where
F: Future<Output = ()>,
{
let (sender, receiver) = mpsc::channel(1);
stream::select(
receiver,
stream::once(f(sender)).filter_map(|_| async { None }),
)
}