I feel like I must be missing something obvious but despite reading tons of docs I have not been able to get this to work. Here's what I'm trying to do:
pub async fn messages(&self) -> Map {
self
.pubsub // pubsub is type tokio::broadcast::Sender<SomeType>
.subscribe()
.into_stream()
.filter(Result::is_ok)
.map(Result::unwrap)
}
so that I then have a simple API to call elsewhere:
let stream = foo
.messages()
.map(|data| match data {
// process the messages
})
Box.pin(stream)
This code works when it's called directly (foo.pubsub.subscribe().into_stream().map()
etc) but how can I get the return type correct so that I can move this into a method? What am I missing?