async fn handle_idle_metric_request_response_event(
        &mut self,
        event: RequestResponseEvent<IdleMetricRequest, IdleMetricResponse>,
    ) {
        trace!("Handle RequestResponseEvent: {:?}", event);
        match event {
            RequestResponseEvent::Message { message, .. } => match message {
                RequestResponseMessage::Request { channel, .. } => {
                    self.event_sender
                        .send(PyrsiaEvent::IdleMetricRequest { channel })
                        .await
                        .expect("Event receiver not to be dropped.");
                }
                RequestResponseMessage::Response {
                    request_id,
                    response,
                } => {
                    let _ = self
                        .pending_idle_metric_requests
                        .remove(&request_id)
                        .expect("Request to still be pending.")
                        .send(Ok(response.0));
                }
            },
            RequestResponseEvent::InboundFailure { .. } => {}
            RequestResponseEvent::OutboundFailure {
                request_id, error, ..
            } => {
                let _ = self
                    .pending_idle_metric_requests
                    .remove(&request_id)
                    .expect("Request to still be pending.")
                    .send(Err(error.into()));
            }
            RequestResponseEvent::ResponseSent { .. } => {}
        }
    }
// Handles events from the `RequestResponse` for peer metric exchange
// network behaviour.
Handles events from the `RequestResponse` for peer metric exchange
network behaviour.
Handles events from the ` RequestResponse ` for peer metric exchange network behaviour .
async fn handle_idle_metric_request_response_event(
        &mut self,
        event: RequestResponseEvent<IdleMetricRequest, IdleMetricResponse>,
    ) {
        trace!("Handle RequestResponseEvent: {:?}", event);
        match event {
            RequestResponseEvent::Message { message, .. } => match message {
                RequestResponseMessage::Request { channel, .. } => {
                    self.event_sender
                        .send(PyrsiaEvent::IdleMetricRequest { channel })
                        .await
                        .expect("Event receiver not to be dropped.");
                }
                RequestResponseMessage::Response {
                    request_id,
                    response,
                } => {
                    let _ = self
                        .pending_idle_metric_requests
                        .remove(&request_id)
                        .expect("Request to still be pending.")
                        .send(Ok(response.0));
                }
            },
            RequestResponseEvent::InboundFailure { .. } => {}
            RequestResponseEvent::OutboundFailure {
                request_id, error, ..
            } => {
                let _ = self
                    .pending_idle_metric_requests
                    .remove(&request_id)
                    .expect("Request to still be pending.")
                    .send(Err(error.into()));
            }
            RequestResponseEvent::ResponseSent { .. } => {}
        }
    }
async fn handle_idle_metric_request_response_event ( & mut self , event : RequestResponseEvent < IdleMetricRequest , IdleMetricResponse > , ) { trace ! ( " " event ) ; match event { RequestResponseEvent :: Message { message , .. } => match message { RequestResponseMessage :: Request { channel , .. } => { self . event_sender . send ( PyrsiaEvent :: IdleMetricRequest { channel } ) . await . expect ( " " ) ; } RequestResponseMessage :: Response { request_id , response , } => { let _ = self . pending_idle_metric_requests . remove ( & request_id ) . expect ( " " ) . send ( Ok ( response . 0 ) ) ; } } , RequestResponseEvent :: InboundFailure { .. } => { } RequestResponseEvent :: OutboundFailure { request_id , error , .. } => { let _ = self . pending_idle_metric_requests . remove ( & request_id ) . expect ( " " ) . send ( Err ( error . into ( ) ) ) ; } RequestResponseEvent :: ResponseSent { .. } => { } } }
Handles events from the `RequestResponse` for peer metric exchange
network behaviour.
Handles events from the ` RequestResponse ` for peer metric exchange network behaviour .
&mut self
event
RequestResponseEvent<IdleMetricRequest, IdleMetricResponse>
&mut self
event
RequestResponseEvent<IdleMetricRequest, IdleMetricResponse>