Often the best way to solve these kinds of problems is the "actor pattern". You have one spawned task which contains the session/connection (so you don't need a Mutex), and it receives a request through a channel (like tokio::sync::mpsc) and then interacts with the server to fetch that email or whatever and replies through a oneshot channel it was given with the request, and then goes back to waiting for a request.
#static imap session
3 messages · Page 1 of 1 (latest)