/// Enqueues a request that will be send to the RPC server iff we don't have
/// more than 'inflight_requests' requests waiting to be consumed by the
/// client.
Enqueues a request that will be send to the RPC server iff we don't have
more than 'inflight_requests' requests waiting to be consumed by the
client.
Enqueues a request that will be send to the RPC server iff we don ' t have more than ' inflight_requests ' requests waiting to be consumed by the client .
pub fn send(&mut self, request: Request) -> Result<(), RpcBridgeSendError<Request>> {
        // Accept the request iff we can secure capacity for sending the response back.
        let permit = match self.tx.clone().try_reserve_owned() {
            Ok(permit) => permit,
            Err(err) => {
                return match err {
                    TrySendError::Full(_) => Err(RpcBridgeSendError::Full(request)),
                    TrySendError::Closed(_) => Err(RpcBridgeSendError::Closed(request)),
                };
            }
        };
        // Construct the future for obtaining the response but don't not poll it yet.
        let response_fut = (self.func)(request);
        // Spawn an async task that polls the response and once available send the
        // response over to the channel making it available to the client.
        self.rt_handle.spawn(async move {
            let response = response_fut.await;
            permit.send(response);
        });
        Ok(())
    }
pub fn send ( & mut self , request : Request ) -> Result < ( ) , RpcBridgeSendError < Request > > { // Accept the request iff we can secure capacity for sending the response back. let permit = match self . tx . clone ( ) . try_reserve_owned ( ) { Ok ( permit ) => permit , Err ( err ) => { return match err { TrySendError :: Full ( _ ) => Err ( RpcBridgeSendError :: Full ( request ) ) , TrySendError :: Closed ( _ ) => Err ( RpcBridgeSendError :: Closed ( request ) ) , } ; } } ; // Construct the future for obtaining the response but don't not poll it yet. let response_fut = ( self . func ) ( request ) ; // Spawn an async task that polls the response and once available send the // response over to the channel making it available to the client. self . rt_handle . spawn ( async move { let response = response_fut . await ; permit . send ( response ) ; } ) ; Ok ( ( ) ) }
Enqueues a request that will be send to the RPC server iff we don't have
more than 'inflight_requests' requests waiting to be consumed by the
client.
Enqueues a request that will be send to the RPC server iff we don ' t have more than ' inflight_requests ' requests waiting to be consumed by the client .
&mut self
request
Request