Ensure that stream_new_messages returns something that is Send

Makes sure that this can be used on multi-threaded executors

Well, technically it doesn't fully guarantee it, but the error
being non-Send is very unlikely. Anyway, if the returned Stream
is not Send, the future definitely won't be, so we will assert
that at least.
This commit is contained in:
Nick Krichevsky 2022-06-01 23:07:47 -04:00
parent 80381811bc
commit e23dad1f41

View file

@ -59,7 +59,7 @@ impl From<email::StreamSetupError> for StreamSetupError {
pub async fn stream_new_messages<S: Spawn + Send + Sync + Clone + 'static>(
spawner: &S,
imap_config: IMAPConfig,
) -> Result<impl Stream<Item = Vec<u8>>, StreamSetupError> {
) -> Result<impl Stream<Item = Vec<u8>> + Send, StreamSetupError> {
let session_generator_arc = Arc::new(ConfigSessionGenerator::new(imap_config.clone()));
let watcher = email::inbox::watch_for_new_messages(spawner, session_generator_arc.clone())
.await