Struct zmq_rs::Socket
[−]
[src]
pub struct Socket { /* fields omitted */ }
Methods
impl Socket
[src]
fn from_raw(socket: *mut c_void) -> Socket
[src]
fn close(&mut self) -> Result<(), Error>
[src]
Close 0MQ socket
Binding of int zmq_close (void *s);
It's not mandatory to call this function since socket can be closed automatically on dropping The function will destroy this socket. Any outstanding messages physically received from the network but not yet received by the application with recv() shall be discarded. The behaviour for discarding messages sent by the application with send() but not yet physically transferred to the network depends on the value of the ZMQ_LINGER socket option for the specified socket.
fn bind(&mut self, endpoint: &str) -> Result<(), Error>
[src]
Accept incoming connections on a socket
Binding of int zmq_bind (void *socket, const char *endpoint);
The function binds the socket to a local endpoint and then accepts incoming connections on that endpoint.
fn connect(&mut self, endpoint: &str) -> Result<(), Error>
[src]
Create outgoing connection from socket
Binding of int zmq_connect (void *socket, const char *endpoint);
The function connects the socket to an endpoint and then accepts incoming connections on that endpoint.
fn unbind(&mut self, endpoint: &str) -> Result<(), Error>
[src]
Stop accepting connections on a socket
Binding of int zmq_unbind (void *socket, const char *endpoint);
The function will unbind a socket specified by the socket argument from the endpoint specified by the endpoint argument.
fn disconnect(&mut self, endpoint: &str) -> Result<(), Error>
[src]
Disconnect a socket
Binding of int zmq_disconnect (void *socket, const char *endpoint);
The function will disconnect socket from the endpoint specified by the endpoint argument. Any outstanding messages physically received from the network but not yet received by the application with recv() will be discarded. The behaviour for discarding messages sent by the application with send() but not yet physically transferred to the network depends on the value of the ZMQ_LINGER socket option for the socket.
fn send_msg(&mut self, msg: Message, flags: SocketFlag) -> Result<i32, Error>
[src]
Send a message part on a socket
Binding of int zmq_msg_send (zmq_msg_t *msg, void *socket, int flags);
fn recv_into_msg(
&mut self,
msg: &mut Message,
flags: SocketFlag
) -> Result<i32, Error>
[src]
&mut self,
msg: &mut Message,
flags: SocketFlag
) -> Result<i32, Error>
Receive a message part from a socket
Binding of int zmq_msg_recv (zmq_msg_t *msg, void *socket, int flags);
fn recv_msg(&mut self, flags: SocketFlag) -> Result<Message, Error>
[src]
Receive a message part from a socket
Binding of int zmq_msg_recv (zmq_msg_t *msg, void *socket, int flags);
fn send_bytes(&mut self, data: &[u8], flags: SocketFlag) -> Result<i32, Error>
[src]
Send bytes on a socket
Data will be copied into a Message object in order to be sent.
fn send_const_bytes(
&mut self,
data: &'static [u8],
flags: SocketFlag
) -> Result<i32, Error>
[src]
&mut self,
data: &'static [u8],
flags: SocketFlag
) -> Result<i32, Error>
Send a constant-memory message part on a socket
Binding of ZMQ_EXPORT int zmq_send_const (void *s, const void *buf, size_t len, int flags);
The message buffer is assumed to be constant-memory(static) and will therefore not be copied or deallocated in any way
fn send_str(&mut self, data: &str, flags: SocketFlag) -> Result<i32, Error>
[src]
Send a UTF-8 string on socket
fn recv_bytes(&mut self, flags: SocketFlag) -> Result<Vec<u8>, Error>
[src]
Receive bytes from a socket
fn recv_bytes_into_slice(
&mut self,
buffer: &mut [u8],
flags: SocketFlag
) -> Result<i32, Error>
[src]
&mut self,
buffer: &mut [u8],
flags: SocketFlag
) -> Result<i32, Error>
Receive bytes into a mutable slice
Caution
Any bytes exceeding the length of buffer will be truncated.
fn recv_string(
&mut self,
flags: SocketFlag
) -> Result<Result<String, Vec<u8>>, Error>
[src]
&mut self,
flags: SocketFlag
) -> Result<Result<String, Vec<u8>>, Error>
Receive a UTF-8 string from socket
fn socket_monitor(
&mut self,
endpoint: &str,
events: &Vec<SocketEvent>
) -> Result<(), Error>
[src]
&mut self,
endpoint: &str,
events: &Vec<SocketEvent>
) -> Result<(), Error>
Monitor socket events
Binding of int zmq_socket_monitor (void *socket, char *endpoint, int events);
The method lets an application thread track socket events (like connects) on a ZeroMQ socket
fn run_proxy(frontend: &mut Socket, backend: &mut Socket) -> Result<(), Error>
[src]
Start built-in 0MQ proxy
Binding of int zmq_proxy (const void *frontend, const void *backend, const void *capture);
The function starts the built-in ØMQ proxy in the current application thread.
fn run_proxy_ex(
frontend: &mut Socket,
backend: &mut Socket,
capture: Option<&mut Socket>,
control: Option<&mut Socket>
) -> Result<(), Error>
[src]
frontend: &mut Socket,
backend: &mut Socket,
capture: Option<&mut Socket>,
control: Option<&mut Socket>
) -> Result<(), Error>
Start built-in 0MQ proxy
Binding of int zmq_proxy (const void *frontend, const void *backend, const void *capture);
or
int zmq_proxy_steerable (const void *frontend, const void *backend, const void *capture, const void *control);
The function starts the built-in ØMQ proxy in the current application thread. The proxy will send all messages, received on both frontend and backend, to the capture socket. The capture socket should be a ZMQ_PUB, ZMQ_DEALER, ZMQ_PUSH, or ZMQ_PAIR socket. If the control socket is not None, the proxy supports control flow. If PAUSE is received on this socket, the proxy suspends its activities. If RESUME is received, it goes on. If TERMINATE is received, it terminates smoothly. At start, the proxy runs normally as if run_proxy was used.
fn as_poll_item(&self) -> PollItem
[src]
Create a poll item from current socket
Safty
There is no lifetime guarantee that poll item does not live out socket
fn poll(items: &mut [PollItem], nitems: i32, timeout: i32) -> Result<i32, Error>
[src]
input/output multiplexing
Binding of int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout);