fn handle_packet(
    packet: Option<(DeviceId, SnoopPacket)>,
    snooper: Snooper,
    snoopers: &mut ConcurrentSnooperPacketFutures,
    subscribers: &mut SubscriptionManager,
    packet_logs: &mut PacketLogs,
    truncate_payload: Option<usize>,
) {
    match packet {
        Some((device, mut packet)) => {
            fx_vlog!(2, "Received packet from {:?}.", snooper.device_path);
            if let Some(len) = truncate_payload {
                packet.payload.truncate(len);
            }
            subscribers.notify(&device, &mut packet);
            packet_logs.log_packet(&device, packet);
            snoopers.push(snooper.into_future());
        }
        None => {
            // TODO (belgum):
            // It's unclear to me what the correct response is in this case. Should we:
            //                  - bring down and restart the bt-snoop service
            //                  - remove the snooper for that channel
            //                  - attempt to reinit snoop stream
            //                  - clean up logs for that device (very likely not!)
            let snooper = Snooper::new(snooper.device_path);
            match snooper {
                Ok(snooper) => snoopers.push(snooper.into_future()),
                Err(e) => fx_log_warn!("Attempt to re-open snoop channel failed: {}", e),
            }
        }
    }
}
/// Handle a possible incoming packet. Returns an error if the snoop channel is closed and cannot
/// be reopened.
Handle a possible incoming packet. Returns an error if the snoop channel is closed and cannot
be reopened.
Handle a possible incoming packet . Returns an error if the snoop channel is closed and cannot be reopened .
fn handle_packet(
    packet: Option<(DeviceId, SnoopPacket)>,
    snooper: Snooper,
    snoopers: &mut ConcurrentSnooperPacketFutures,
    subscribers: &mut SubscriptionManager,
    packet_logs: &mut PacketLogs,
    truncate_payload: Option<usize>,
) {
    match packet {
        Some((device, mut packet)) => {
            fx_vlog!(2, "Received packet from {:?}.", snooper.device_path);
            if let Some(len) = truncate_payload {
                packet.payload.truncate(len);
            }
            subscribers.notify(&device, &mut packet);
            packet_logs.log_packet(&device, packet);
            snoopers.push(snooper.into_future());
        }
        None => {
            // TODO (belgum):
            // It's unclear to me what the correct response is in this case. Should we:
            //                  - bring down and restart the bt-snoop service
            //                  - remove the snooper for that channel
            //                  - attempt to reinit snoop stream
            //                  - clean up logs for that device (very likely not!)
            let snooper = Snooper::new(snooper.device_path);
            match snooper {
                Ok(snooper) => snoopers.push(snooper.into_future()),
                Err(e) => fx_log_warn!("Attempt to re-open snoop channel failed: {}", e),
            }
        }
    }
}
fn handle_packet ( packet : Option < ( DeviceId , SnoopPacket ) > , snooper : Snooper , snoopers : & mut ConcurrentSnooperPacketFutures , subscribers : & mut SubscriptionManager , packet_logs : & mut PacketLogs , truncate_payload : Option < usize > , ) { match packet { Some ( ( device , mut packet ) ) => { fx_vlog ! ( 2 " " snooper device_path ) ; if let Some ( len ) = truncate_payload { packet . payload . truncate ( len ) ; } subscribers . notify ( & device , & mut packet ) ; packet_logs . log_packet ( & device , packet ) ; snoopers . push ( snooper . into_future ( ) ) ; } None => { // TODO (belgum): // It's unclear to me what the correct response is in this case. Should we: //                  - bring down and restart the bt-snoop service //                  - remove the snooper for that channel //                  - attempt to reinit snoop stream //                  - clean up logs for that device (very likely not!) let snooper = Snooper :: new ( snooper . device_path ) ; match snooper { Ok ( snooper ) => snoopers . push ( snooper . into_future ( ) ) , Err ( e ) => fx_log_warn ! ( " " e ) , } } } }
Handle a possible incoming packet.
Handle a possible incoming packet .
packet
Option<(DeviceId, SnoopPacket)>
snooper
Snooper
snoopers
&mut ConcurrentSnooperPacketFutures
subscribers
&mut SubscriptionManager
packet_logs
&mut PacketLogs
truncate_payload
Option<usize>
packet
Option<(DeviceId, SnoopPacket)>
snooper
Snooper
snoopers
&mut ConcurrentSnooperPacketFutures
subscribers
&mut SubscriptionManager
packet_logs
&mut PacketLogs
truncate_payload
Option<usize>