This is a small crate for writing network services, with the following particular features:
- Asynchronous communication of serde-serializable types.
- Symmetric / peer-to-peer: no distinguished clients or servers.
- Pipelined: many requests allowed in flight at once.
- Support for "one-way" requests with no paired responses.
- Async-ecosystem agnostic: doesn't drag in async_std or tokio (except as dev-dependencies for testing).
There is no integrated event loop nor task spawning: you are expected to call methods on this crate's main Connection type from your own tasks or async functions.
This crate expects callers to take three main steps:
- Enqueueing a message to send, either a one-way message via Connection::enqueue_oneway which generates no corresponding future, or via Connection::enqueue_request which generates a future that will be filled in when a paired response arrives.
- Calling Connection::advance and awaiting its returned future (typically in a loop) to advance the peer through internal steps of dequeueing, sending, receiveing, serving, responding, and fulfilling response futures. This requires the caller to provide callbacks.
- Optionally awaiting the response future generated in the first step.
Sequencing these steps and integrating them into a set of async tasks or event loops is left to the caller. Some examples are present in the test module.
Abraham Niclas Edelcrantz (1754-1821) developed the Swedish optical telegraph system, which operated from 1795-1881.
Any IO facility that can be sent or received on must implement this trait.
Any message that can be sent or received -- as a request, response, or one-way -- must implement this trait.