// Report all calls to the given peer. Panics if `id` does not point to a valid peer in the
// peers map.
Report all calls to the given peer. Panics if `id` does not point to a valid peer in the
peers map.
Report all calls to the given peer . Panics if ` id ` does not point to a valid peer in the peers map .
fn report_calls(
        self,
        id: PeerId,
        mut inner: futures::lock::MutexGuard<'_, TestCallManagerInner>,
    ) -> Result<(), Error> {
        // keep popping from unreported until we get one
        // that is also found in the calls map.
        while let Some(cid) = inner.unreported_calls.pop_front() {
            if let Some(call) = inner.calls.get(&cid) {
                let remote = call.remote.clone();
                let state = call.state;
                drop(call);
                let (client_end, stream) =
                    fidl::endpoints::create_request_stream::<CallMarker>()
                        .map_err(|e| format_err!("Error creating fidl endpoints: {}", e))?;
                let peer = inner.peers.get_mut(&id).expect("peer just added");
                let res = peer
                    .call_responder
                    .take()
                    .expect("just put here")
                    .send(client_end, &remote, state);
                if let Ok(()) = res {
                    let task = fasync::Task::local(self.manage_call(id, cid, stream));
                    peer.call_tasks.insert(cid, task);
                    inner.calls.get_mut(&cid).expect("still here").peer_id = Some(id);
                }
                break;
            }
        }
        Ok(())
    }
fn report_calls ( self , id : PeerId , mut inner : futures :: lock :: MutexGuard < ' _ , TestCallManagerInner > , ) -> Result < ( ) , Error > { // keep popping from unreported until we get one // that is also found in the calls map. while let Some ( cid ) = inner . unreported_calls . pop_front ( ) { if let Some ( call ) = inner . calls . get ( & cid ) { let remote = call . remote . clone ( ) ; let state = call . state ; drop ( call ) ; let ( client_end , stream ) = fidl :: endpoints :: create_request_stream :: < CallMarker > ( ) . map_err ( | e | format_err ! ( " " e ) ) ? ; let peer = inner . peers . get_mut ( & id ) . expect ( " " ) ; let res = peer . call_responder . take ( ) . expect ( " " ) . send ( client_end , & remote , state ) ; if let Ok ( ( ) ) = res { let task = fasync :: Task :: local ( self . manage_call ( id , cid , stream ) ) ; peer . call_tasks . insert ( cid , task ) ; inner . calls . get_mut ( & cid ) . expect ( " " ) . peer_id = Some ( id ) ; } break ; } } Ok ( ( ) ) }
Report all calls to the given peer.
Report all calls to the given peer .
self
id
PeerId
inner
futures::lock::MutexGuard<'_, TestCallManagerInner>