pub fn pn(&mut self, pn: PacketNumber, pn_len: usize) {
        if self.remaining() < 4 {
            self.limit = 0;
            return;
        }

        // Reserve space for a length in long headers.
        if self.is_long() {
            self.offsets.len = self.encoder.len();
            self.encoder.encode(&[0; 2]);
        }

        // This allows the input to be >4, which is absurd, but we can eat that.
        let pn_len = min(MAX_PACKET_NUMBER_LEN, pn_len);
        debug_assert_ne!(pn_len, 0);
        // Encode the packet number and save its offset.
        let pn_offset = self.encoder.len();
        self.encoder.encode_uint(pn_len, pn);
        self.offsets.pn = pn_offset..self.encoder.len();

        // Now encode the packet number length and save the header length.
        self.encoder[self.header.start] |= u8::try_from(pn_len - 1).unwrap();
        self.header.end = self.encoder.len();
        self.pn = pn;
    }
/// Add a packet number of the given size.
/// For a long header packet, this also inserts a dummy length.
/// The length is filled in after calling `build`.
/// Does nothing if there isn't 4 bytes available other than render this builder
/// unusable; if `remaining()` returns 0 at any point, call `abort()`.
Add a packet number of the given size.
For a long header packet, this also inserts a dummy length.
The length is filled in after calling `build`.
Does nothing if there isn't 4 bytes available other than render this builder
unusable; if `remaining()` returns 0 at any point, call `abort()`.
Add a packet number of the given size . For a long header packet this also inserts a dummy length . The length is filled in after calling ` build ` . Does nothing if there isn ' t 4 bytes available other than render this builder unusable ; if ` remaining () ` returns 0 at any point call ` abort () ` .
pub fn pn(&mut self, pn: PacketNumber, pn_len: usize) {
        if self.remaining() < 4 {
            self.limit = 0;
            return;
        }
        // Reserve space for a length in long headers.
        if self.is_long() {
            self.offsets.len = self.encoder.len();
            self.encoder.encode(&[0; 2]);
        }
        // This allows the input to be >4, which is absurd, but we can eat that.
        let pn_len = min(MAX_PACKET_NUMBER_LEN, pn_len);
        debug_assert_ne!(pn_len, 0);
        // Encode the packet number and save its offset.
        let pn_offset = self.encoder.len();
        self.encoder.encode_uint(pn_len, pn);
        self.offsets.pn = pn_offset..self.encoder.len();
        // Now encode the packet number length and save the header length.
        self.encoder[self.header.start] |= u8::try_from(pn_len - 1).unwrap();
        self.header.end = self.encoder.len();
        self.pn = pn;
    }
pub fn pn ( & mut self , pn : PacketNumber , pn_len : usize ) { if self . remaining ( ) < 4 { self . limit = 0 ; return ; } // Reserve space for a length in long headers. if self . is_long ( ) { self . offsets . len = self . encoder . len ( ) ; self . encoder . encode ( & [ 0 ; 2 ] ) ; } // This allows the input to be >4, which is absurd, but we can eat that. let pn_len = min ( MAX_PACKET_NUMBER_LEN , pn_len ) ; debug_assert_ne ! ( pn_len 0 ) ; // Encode the packet number and save its offset. let pn_offset = self . encoder . len ( ) ; self . encoder . encode_uint ( pn_len , pn ) ; self . offsets . pn = pn_offset .. self . encoder . len ( ) ; // Now encode the packet number length and save the header length. self . encoder [ self . header . start ] |= u8 :: try_from ( pn_len - 1 ) . unwrap ( ) ; self . header . end = self . encoder . len ( ) ; self . pn = pn ; }
Add a packet number of the given size.
Add a packet number of the given size .
&mut self
pn
PacketNumber
pn_len
usize