pub fn create_rpc<T, U>(
        &mut self,
        name: &'static str,
        callback: RpcCallback<T, U>,
    ) -> Result<(), IoError>
    where
        T: Debug + DeserializeOwned + Serialize + 'static,
        U: Debug + DeserializeOwned + Serialize + 'static,
    {
        if self.rpc.contains_key(name) {
            let msg = format!("RPC exists: {}", name);
            log::trace!("{}", msg);
            return Err(IoError::new(ErrorKind::AlreadyExists, msg));
        }

        let server = match self.get_rpc_from_config(&self.name, name) {
            Some(addr) => {
                if addr.ip() != IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)) {
                    let msg = format!(
                        "RPC {} refers to remote endpoint: {}",
                        Process::config_name(&self.name, name),
                        addr
                    );
                    return Err(IoError::new(ErrorKind::AddrNotAvailable, msg));
                }

                RpcServer::with_tcp_port(name, addr.port(), callback)
            }
            None => {
                let socket_path = self.unix_socket_base()?.as_path().with_extension(name);
                RpcServer::with_unix_socket(name, &socket_path, callback)
            }
        };

        assert!(self.rpc.insert(String::from(name), server).is_none());
        Ok(())
    }
/// Create an RPC server.
///
/// If the RPC server is defined in the config the `Process` was initialized with, and the IP
/// address in the config is localhost, then the RPC server is a TCP endpoint. If the address
/// for the RPC server is not a localhost address, an error is returned. IF the RPC server is
/// not listed in the config, then the endpoint is a Unix socket based on the RPC name, Process
/// name, and config path.
///
/// Args:
/// * `name`: The name to assign the RPC so clients can call it.
/// * `callback`: The function that is called when the RPC server receives data.
Create an RPC server.
If the RPC server is defined in the config the `Process` was initialized with, and the IP
address in the config is localhost, then the RPC server is a TCP endpoint. If the address
for the RPC server is not a localhost address, an error is returned. IF the RPC server is
not listed in the config, then the endpoint is a Unix socket based on the RPC name, Process
name, and config path.

`name`: The name to assign the RPC so clients can call it.
`callback`: The function that is called when the RPC server receives data.
Create an RPC server . If the RPC server is defined in the config the ` Process ` was initialized with and the IP address in the config is localhost then the RPC server is a TCP endpoint . If the address for the RPC server is not a localhost address an error is returned . IF the RPC server is not listed in the config then the endpoint is a Unix socket based on the RPC name Process name and config path . ` name ` : The name to assign the RPC so clients can call it . ` callback ` : The function that is called when the RPC server receives data .
pub fn create_rpc<T, U>(
        &mut self,
        name: &'static str,
        callback: RpcCallback<T, U>,
    ) -> Result<(), IoError>
    where
        T: Debug + DeserializeOwned + Serialize + 'static,
        U: Debug + DeserializeOwned + Serialize + 'static,
    {
        if self.rpc.contains_key(name) {
            let msg = format!("RPC exists: {}", name);
            log::trace!("{}", msg);
            return Err(IoError::new(ErrorKind::AlreadyExists, msg));
        }
        let server = match self.get_rpc_from_config(&self.name, name) {
            Some(addr) => {
                if addr.ip() != IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)) {
                    let msg = format!(
                        "RPC {} refers to remote endpoint: {}",
                        Process::config_name(&self.name, name),
                        addr
                    );
                    return Err(IoError::new(ErrorKind::AddrNotAvailable, msg));
                }
                RpcServer::with_tcp_port(name, addr.port(), callback)
            }
            None => {
                let socket_path = self.unix_socket_base()?.as_path().with_extension(name);
                RpcServer::with_unix_socket(name, &socket_path, callback)
            }
        };
        assert!(self.rpc.insert(String::from(name), server).is_none());
        Ok(())
    }
pub fn create_rpc < T , U > ( & mut self , name : & ' static str , callback : RpcCallback < T , U > , ) -> Result < ( ) , IoError > where T : Debug + DeserializeOwned + Serialize + ' static , U : Debug + DeserializeOwned + Serialize + ' static , { if self . rpc . contains_key ( name ) { let msg = format ! ( " " name ) ; log :: trace ! ( " " msg ) ; return Err ( IoError :: new ( ErrorKind :: AlreadyExists , msg ) ) ; } let server = match self . get_rpc_from_config ( & self . name , name ) { Some ( addr ) => { if addr . ip ( ) != IpAddr :: V4 ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) { let msg = format ! ( " " Process config_name ( self name name ) addr ) ; return Err ( IoError :: new ( ErrorKind :: AddrNotAvailable , msg ) ) ; } RpcServer :: with_tcp_port ( name , addr . port ( ) , callback ) } None => { let socket_path = self . unix_socket_base ( ) ? . as_path ( ) . with_extension ( name ) ; RpcServer :: with_unix_socket ( name , & socket_path , callback ) } } ; assert ! ( self rpc insert ( String from ( name ) server ) is_none ( ) ) ; Ok ( ( ) ) }
Create an RPC server.
Create an RPC server .
&mut self
name
&'static str
callback
RpcCallback<T, U>
&mut self
name
&'static str
callback
RpcCallback<T, U>