use crate::{ subscription::{EventStream, Recipe}, Event, Hasher, }; use iced_futures::futures::future; use iced_futures::futures::StreamExt; use iced_futures::BoxStream; pub struct Events { pub(super) f: fn(Event) -> Option, } impl Recipe for Events where Message: 'static + Send, { type Output = Message; fn hash(&self, state: &mut Hasher) { use std::hash::Hash; struct Marker; std::any::TypeId::of::().hash(state); self.f.hash(state); } fn stream( self: Box, event_stream: EventStream, ) -> BoxStream { event_stream .filter_map(move |event| future::ready((self.f)(event))) .boxed() } }