namib-project / libcoap-rs

Rust bindings to and wrapper around the libcoap C library
BSD 2-Clause "Simplified" License
6 stars 1 forks source link

Support for async #2

Open pulsastrix opened 1 year ago

pulsastrix commented 1 year ago

Summary

Allow libcoap-rs to be used inside of async runtimes like Tokio without spawning a blocking thread.

Description

The libcoap C-library has its own implementation of IO handling described in the coap_io man page. This implementation involves setting up epoll or select to poll for IO events.

This does not work well with async runtimes provided in Rust, because they are designed to handle polling for IO events on their own and to notify other parts of the software when IO happens. Because of this, libcoap will have to be run in a separate blocking thread if an async runtime is to be used. To solve this, we should adapt libcoap to allow using other IO loops defined in rust (like the aforementioned async runtimes)

Implementation steps

(Issue moved over from GitLab)