fn receive_tasks_if_needed(&mut self) -> Option<Result<(), BoxError>> {
        if self.guards.is_empty() {
            match self.handle_rx.try_recv() {
                // The tasks haven't been sent yet.
                Err(TryRecvError::Empty) => Some(Ok(())),

                // The tasks have been sent, but not consumed.
                Ok(handles) => {
                    // Currently, the peer set treats an empty background task set as an error.
                    //
                    // TODO: refactor `handle_rx` and `guards` into an enum
                    //       for the background task state: Waiting/Running/Shutdown.
                    assert!(
                        !handles.is_empty(),
                        "the peer set requires at least one background task"
                    );

                    self.guards.extend(handles);

                    None
                }

                // The tasks have been sent and consumed, but then they exited.
                //
                // Correctness: the peer set must receive at least one task.
                //
                // TODO: refactor `handle_rx` and `guards` into an enum
                //       for the background task state: Waiting/Running/Shutdown.
                Err(TryRecvError::Closed) => {
                    Some(Err("all peer set background tasks have exited".into()))
                }
            }
        } else {
            None
        }
    }
/// Receive background tasks, if they've been sent on the channel,
/// but not consumed yet.
///
/// Returns a result representing the current task state,
/// or `None` if the background tasks should be polled to check their state.
Receive background tasks, if they've been sent on the channel,
but not consumed yet.

Returns a result representing the current task state,
or `None` if the background tasks should be polled to check their state.
Receive background tasks if they ' ve been sent on the channel but not consumed yet . Returns a result representing the current task state or ` None ` if the background tasks should be polled to check their state .
fn receive_tasks_if_needed(&mut self) -> Option<Result<(), BoxError>> {
        if self.guards.is_empty() {
            match self.handle_rx.try_recv() {
                // The tasks haven't been sent yet.
                Err(TryRecvError::Empty) => Some(Ok(())),
                // The tasks have been sent, but not consumed.
                Ok(handles) => {
                    // Currently, the peer set treats an empty background task set as an error.
                    //
                    // TODO: refactor `handle_rx` and `guards` into an enum
                    //       for the background task state: Waiting/Running/Shutdown.
                    assert!(
                        !handles.is_empty(),
                        "the peer set requires at least one background task"
                    );
                    self.guards.extend(handles);
                    None
                }
                // The tasks have been sent and consumed, but then they exited.
                //
                // Correctness: the peer set must receive at least one task.
                //
                // TODO: refactor `handle_rx` and `guards` into an enum
                //       for the background task state: Waiting/Running/Shutdown.
                Err(TryRecvError::Closed) => {
                    Some(Err("all peer set background tasks have exited".into()))
                }
            }
        } else {
            None
        }
    }
fn receive_tasks_if_needed ( & mut self ) -> Option < Result < ( ) , BoxError > > { if self . guards . is_empty ( ) { match self . handle_rx . try_recv ( ) { // The tasks haven't been sent yet. Err ( TryRecvError :: Empty ) => Some ( Ok ( ( ) ) ) , // The tasks have been sent, but not consumed. Ok ( handles ) => { // Currently, the peer set treats an empty background task set as an error. // // TODO: refactor `handle_rx` and `guards` into an enum //       for the background task state: Waiting/Running/Shutdown. assert ! ( handles is_empty ( ) " " ) ; self . guards . extend ( handles ) ; None } // The tasks have been sent and consumed, but then they exited. // // Correctness: the peer set must receive at least one task. // // TODO: refactor `handle_rx` and `guards` into an enum //       for the background task state: Waiting/Running/Shutdown. Err ( TryRecvError :: Closed ) => { Some ( Err ( " " . into ( ) ) ) } } } else { None } }
Receive background tasks, if they've been sent on the channel,
but not consumed yet.
Receive background tasks if they ' ve been sent on the channel but not consumed yet .
&mut self