You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: packet.rs
    path of file: ./repos/ockam/implementations/rust/ockam/ockam_transport_ble/src/driver
    
    the code of the file until where you have to start completion: use core::cmp::Ordering;

use crate::driver::BleEvent;
use crate::driver::CHARACTERISTIC_VALUE_LENGTH;
use crate::driver::MAX_OCKAM_MESSAGE_LENGTH;
use crate::error::BleError;

use ockam_core::Result;

/// PacketBuffer
pub struct PacketBuffer {
    fragment_len: usize,
    buffer: [u8; MAX_OCKAM_MESSAGE_LENGTH],
    packet_len: usize,
    offset: usize,
}

impl Default for PacketBuffer {
    fn default() -> Self {
        Self {
            fragment_len: CHARACTERISTIC_VALUE_LENGTH,
            buffer: [0_u8; MAX_OCKAM_MESSAGE_LENGTH],
            packet_len: 0,
            offset: 0,
        }
    }
}

impl PacketBuffer {
    pub fn packet_len(&self) -> usize {
        self.packet_len
    }

    pub fn reset(&mut self) {
        *self = Self::defa
    
    pub fn receive_packet_length(&mut self, fragment: &[u8]) -> Option<usize> {
        if fragment.len() != 8 {
            return None;
        }

        let mut buffer = [0_u8; 8];
        buffer.copy_from_slice(&fragment[..8]);
        let packet_len = u64::from_be_bytes(buffer);
        if packet_len > self.buffer.len() as u64 {
            error!("Packet is too long for packet buffer: {}", packet_len);
            return None;
        }

        // TODO Currently we only support packet lengths up to 2^16
        // bits long.
        //
        // The reason for this is that I'm too lazy right now to setup
        // a control channel for this BLE UART implementation and
        // instead rely on the probability of receiving an 8 byte long
        // packet consisting of 6 zero bytes followed by two bytes
        // that can be non-zero.
        //
        // https://github.com/build-trust/ockam/issues/2514
        if packet_len > (2 << 16) {
            error!(
                "Packet is too long for this implementation.\n \
                    See `ockam_transport_ble/src/packet.rs` for more \
                    information: {}",
                fragment.len()
            );
            return None;
        }

        trace!("Received packet length: {} bytes", packet_len);

        self.reset();
        self.packet_len = packet_len as usize;

        Some(self.packet_len)
    }