1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! # About
//!
//! `async-nng` is a small wrapper that uses the
//! [`async-channel`](https://docs.rs/async-channel/latest/async_channel/) crate alongside the
//! [`nng`](https://docs.rs/nng/latest/nng/) crate to provide types that provide async-await
//! semantics around send and receive operations on an NNG socket.
//!
//! The futures that are constructed by the wrapper types in this crate directly utilize the
//! [`nng::Aio`](https://docs.rs/nng/latest/nng/struct.Aio.html) framework, and do not use any
//! `spawn_blocking`, `unblock`, or send any data to a backing threadpool in order to work. This
//! makes it extremely useful to use in scenarios where the
//! [`blocking`](https://docs.rs/blocking/latest/blocking/) crate or the `tokio` equivalent
//! (`spawn_blocking`) are undesirable.
//!
//! # Installing
//!
//! ```bash
//! $ cargo add async-nng
//! ```
//!
//! # Runtime Selection
//!
//! This crate should work with any of `tokio`, `async-std`, or `smol`. The tests in this crate use
//! `smol` purely to save on the number of dev-dependencies, but there are no types used within
//! this crate itself that rely on spawning tasks or any executor-specific API.
//!
//! # `AsyncContext` and `AsyncSocket`
//!
//! The two primary types provided by this crate are `AsyncContext` and `AsyncSocket`. In almost
//! all instances, one should prefer contexts to sockets when writing asynchronous and concurrent
//! programs. See the documentation for [`AsyncContext`] for more information.
//!
//! [`AsyncSocket`] is provided as well for those using raw-mode sockets or who otherwise cannot
//! take advantage of contexts. Unlike contexts which borrow the underlying [`nng::Socket`],
//! `AsyncSocket` itself is an owning type and owns the socket. An [`AsyncSocket::into_inner`] is
//! provided so that the original socket type can be recovered if there is an error or some other
//! reason to get access to the underlying socket.
//!
//! # Acknowledgements
//!
//! Thanks to `@neachdainn` in the NNG discord (and maintainer of the `nng` crate) for helping me
//! in constructing the MVP for async-await semantics wrapping the `nng` crate.
pub use AsyncContext;
pub use AsyncSocket;