Crate scaproust [−] [src]
Scaproust is an implementation of the nanomsg "Scalability Protocols" in the Rust programming language.
Goals
- Support for all of nanomsg's protocols.
- Support for TCP and IPC transports.
- Idiomatic rust API first, mimic the original C API second.
- Extensibility: allow user code to define additional protocols and transports
Usage
First, build a Session with the transports you need
(this will start the thread performing the actual I/O operations).
Then, use the session to create some Socket,
specifying the communication pattern.
If you want, you can now set some options, like the timeouts.
To plug the sockets, use the connect and bind socket methods.
Finally, use the socket methods send and
recv to exchange messages between sockets.
When in doubts, please refer to the nanomsg manual.
Example
use scaproust::*; use std::time::Duration; let mut session = SessionBuilder::new().with("tcp", Tcp).build().unwrap(); let mut pull = session.create_socket::<Pull>().unwrap(); let mut push = session.create_socket::<Push>().unwrap(); let timeout = Duration::from_millis(250); pull.set_recv_timeout(Some(timeout)).unwrap(); pull.bind("tcp://127.0.0.1:5454").unwrap(); push.set_send_timeout(Some(timeout)).unwrap(); push.connect("tcp://127.0.0.1:5454").unwrap(); push.send(vec![65, 66, 67]).unwrap(); let received = pull.recv().unwrap();
Reexports
pub use core::Message; |
pub use core::PollReq; |
pub use core::PollRes; |
pub use transport::tcp::Tcp; |
pub use proto::pair::Pair; |
pub use proto::publ::Pub; |
pub use proto::sub::Sub; |
pub use proto::req::Req; |
pub use proto::rep::Rep; |
pub use proto::push::Push; |
pub use proto::pull::Pull; |
pub use proto::surv::Surveyor; |
pub use proto::resp::Respondent; |
pub use proto::bus::Bus; |
Modules
core | |
proto |
Scalability protocols provided by scaproust |
transport |
Structs
Endpoint |
Endpoint of a socket. |
Ipc | |
Probe |
Probe is what applications use to poll sockets. |
Session |
Creates sockets and devices. |
SessionBuilder |
Creates the session and starts the I/O thread. |
Socket |
Socket is what applications use to exchange messages. |
Enums
ConfigOption |
Traits
Device |
A device to forward messages between sockets, working like a message broker. It can be used to build complex network topologies. |