fn packet(
        r#type: fixed_header::PacketType,
        flags: fixed_header::PacketFlags,
        variable_header: Option<VariableHeader<'a>>,
        payload: Payload<'a>,
    ) -> Result<Self, EncodeError> {
        let len = u32::try_from(
            variable_header
                .as_ref()
                .map(VariableHeader::encoded_len)
                .unwrap_or(0)
                + payload.encoded_len(),
        )?;

        Ok(Self {
            fixed_header: FixedHeader::new(r#type, flags, len),
            variable_header,
            payload,
        })
    }
/// Create a packet with the given type, flags, variable header and payload.
///
/// Constructs a fixed header with the appropriate `len` field for the given
/// variable header and payload.
Create a packet with the given type, flags, variable header and payload.
Constructs a fixed header with the appropriate `len` field for the given
variable header and payload.
Create a packet with the given type flags variable header and payload . Constructs a fixed header with the appropriate ` len ` field for the given variable header and payload .
fn packet(
        r#type: fixed_header::PacketType,
        flags: fixed_header::PacketFlags,
        variable_header: Option<VariableHeader<'a>>,
        payload: Payload<'a>,
    ) -> Result<Self, EncodeError> {
        let len = u32::try_from(
            variable_header
                .as_ref()
                .map(VariableHeader::encoded_len)
                .unwrap_or(0)
                + payload.encoded_len(),
        )?;
        Ok(Self {
            fixed_header: FixedHeader::new(r#type, flags, len),
            variable_header,
            payload,
        })
    }
fn packet ( r#type : fixed_header :: PacketType , flags : fixed_header :: PacketFlags , variable_header : Option < VariableHeader < ' a > > , payload : Payload < ' a > , ) -> Result < Self , EncodeError > { let len = u32 :: try_from ( variable_header . as_ref ( ) . map ( VariableHeader :: encoded_len ) . unwrap_or ( 0 ) + payload . encoded_len ( ) , ) ? ; Ok ( Self { fixed_header : FixedHeader :: new ( r#type , flags , len ) , variable_header , payload , } ) }
Create a packet with the given type, flags, variable header and payload.
Create a packet with the given type flags variable header and payload .
r#type
fixed_header::PacketType
flags
fixed_header::PacketFlags
variable_header
Option<VariableHeader<'a>>
payload
Payload<'a>