Trait zeromq::Socket

source ·
pub trait Socket: Sized + Send {
    // Required methods
    fn with_options(options: SocketOptions) -> Self;
    fn backend(&self) -> Arc<dyn MultiPeerBackend>;
    fn binds(&mut self) -> &mut HashMap<Endpoint, AcceptStopHandle>;
    fn monitor(&mut self) -> Receiver<SocketEvent>;

    // Provided methods
    fn new() -> Self { ... }
    fn bind<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        endpoint: &'life1 str
    ) -> Pin<Box<dyn Future<Output = ZmqResult<Endpoint>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn unbind<'life0, 'async_trait>(
        &'life0 mut self,
        endpoint: Endpoint
    ) -> Pin<Box<dyn Future<Output = ZmqResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn unbind_all<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = Vec<ZmqError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn connect<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        endpoint: &'life1 str
    ) -> Pin<Box<dyn Future<Output = ZmqResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn close<'async_trait>(
        self
    ) -> Pin<Box<dyn Future<Output = Vec<ZmqError>> + Send + 'async_trait>>
       where Self: 'async_trait { ... }
}

Required Methods§

source

fn with_options(options: SocketOptions) -> Self

source

fn backend(&self) -> Arc<dyn MultiPeerBackend>

source

fn binds(&mut self) -> &mut HashMap<Endpoint, AcceptStopHandle>

source

fn monitor(&mut self) -> Receiver<SocketEvent>

Creates and setups new socket monitor

Subsequent calls to this method each create a new monitor channel. Sender side of previous one is dropped.

Provided Methods§

source

fn new() -> Self

source

fn bind<'life0, 'life1, 'async_trait>( &'life0 mut self, endpoint: &'life1 str ) -> Pin<Box<dyn Future<Output = ZmqResult<Endpoint>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Binds to the endpoint and starts a coroutine to accept new connections on it.

Returns the endpoint resolved to the exact bound location if applicable (port # resolved, for example).

source

fn unbind<'life0, 'async_trait>( &'life0 mut self, endpoint: Endpoint ) -> Pin<Box<dyn Future<Output = ZmqResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Unbinds the endpoint, blocking until the associated endpoint is no longer in use

Errors

May give a ZmqError::NoSuchBind if endpoint isn’t bound. May also give any other zmq errors encountered when attempting to disconnect

source

fn unbind_all<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Vec<ZmqError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Unbinds all bound endpoints, blocking until finished.

source

fn connect<'life0, 'life1, 'async_trait>( &'life0 mut self, endpoint: &'life1 str ) -> Pin<Box<dyn Future<Output = ZmqResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Connects to the given endpoint.

source

fn close<'async_trait>( self ) -> Pin<Box<dyn Future<Output = Vec<ZmqError>> + Send + 'async_trait>>
where Self: 'async_trait,

Disconnects from the given endpoint, blocking until finished.

Errors

May give a ZmqError::NoSuchConnection if endpoint isn’t connected. May also give any other zmq errors encountered when attempting to disconnect. Disconnects all connecttions, blocking until finished. Closes the socket, blocking until all associated binds are closed. This is equivalent to drop(), but with the benefit of blocking until resources are released, and getting any underlying errors.

Returns any encountered errors.

Object Safety§

This trait is not object safe.

Implementors§