/// Retrieves up to `cap` packets sent to a player, if any.
/// If `cap` is set to `None`, all packets will be read.
///
/// Note that this function consumes messages in
/// the network channel until enough packets have been read.
Retrieves up to `cap` packets sent to a player, if any.
If `cap` is set to `None`, all packets will be read.

Note that this function consumes messages in
the network channel until enough packets have been read.
Retrieves up to ` cap ` packets sent to a player if any . If ` cap ` is set to ` None ` all packets will be read . Note that this function consumes messages in the network channel until enough packets have been read .
pub fn received_packets(player: &Player, cap: Option<usize>) -> Vec<Box<dyn Packet>> {
    let mut result = vec![];
    while let Ok(Some(msg)) = player.network_receiver.borrow_mut().try_next() {
        if let ServerToWorkerMessage::SendPacket(pack) = msg {
            result.push(pack);
        }
        if let Some(cap) = cap.as_ref() {
            if result.len() >= *cap {
                break;
            }
        }
    }
    result
}
pub fn received_packets ( player : & Player , cap : Option < usize > ) -> Vec < Box < dyn Packet > > { let mut result = vec ! [ ] ; while let Ok ( Some ( msg ) ) = player . network_receiver . borrow_mut ( ) . try_next ( ) { if let ServerToWorkerMessage :: SendPacket ( pack ) = msg { result . push ( pack ) ; } if let Some ( cap ) = cap . as_ref ( ) { if result . len ( ) >= * cap { break ; } } } result }
Retrieves up to `cap` packets sent to a player, if any.
Retrieves up to ` cap ` packets sent to a player if any .
player
&Player
cap
Option<usize>