Courtesy of Yandros on the Rust Discord.
Implementations for Windows and macOS should be fairly similar, but using the OS' message loop instad of a thread.