rustzmq2 0.1.0

A native async Rust implementation of ZeroMQ
Documentation
use std::future::Future;
use std::io::{self, IoSlice};

#[cfg(all(feature = "smol", not(feature = "tokio")))]
pub(crate) mod smol;
#[cfg(feature = "tokio")]
pub(crate) mod tokio;

/// Async vectored-write capability for a transport write half.
///
/// Separate from `AsyncWrite` because `try_write_vectored` + `writable` are a
/// readiness-based pattern (try → `WouldBlock` → await readiness → retry) that
/// doesn't map onto `AsyncWrite::poll_write`. The vectored write avoids copying
/// frame payloads out of `Bytes` into a single contiguous buffer, which is the
/// whole point of the engine's `VectoredWriter`.
///
/// To add a new runtime, create a sibling module (e.g. `smol.rs`) and
/// implement this trait for that runtime's write half type.
pub trait AsyncVectoredWrite: Send + Sync {
    /// Non-blocking scatter-write. Returns `WouldBlock` when the socket
    /// is not ready to accept data.
    fn try_write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize>;

    /// Await write-readiness. Resolves once the socket can accept data.
    fn writable(&self) -> impl Future<Output = io::Result<()>> + Send + '_;
}