pub fn deserialize(sender: Party, bytes: &[u8]) -> Result<KeRecord, DeserializeError> {
    // The first bit of the first byte is the critical bit.
    let critical = bytes[0] >> 7 == 1;

    // The following 15 bits are the record type number.
    let record_type = u16::from_be_bytes([bytes[0] & 0x7, bytes[1]]);

    // The third and fourth bytes are the body length.
    let length = u16::from_be_bytes([bytes[2], bytes[3]]);

    // The body.
    let body = &bytes[4..4 + usize::from(length)];

    macro_rules! deserialize_body {
        ( $( ($variant:ident, $record:ident) ),* ) => {
            if false {
                // Loop returns ! type.
                loop { }
            } $( else if record_type == $record::record_type() {
                match $record::from_bytes(sender, body) {
                    Ok(record) => KeRecord::$variant(record),
                    Err(error) => return Err(DeserializeError::Parsing(error)),
                }
            } )* else {
                if critical {
                    return Err(DeserializeError::UnknownCriticalRecord);
                } else {
                    return Err(DeserializeError::UnknownNotCriticalRecord);
                }
            }
        };
    }

    let record = deserialize_body!(
        (EndOfMessage, EndOfMessageRecord),
        (NextProtocol, NextProtocolRecord),
        (Error, ErrorRecord),
        (Warning, WarningRecord),
        (AeadAlgorithm, AeadAlgorithmRecord),
        (NewCookie, NewCookieRecord),
        (Server, ServerRecord),
        (Port, PortRecord)
    );

    Ok(record)
}
/// Deserialize the network bytes into the record.
///
/// # Panics
///
/// If slice is shorter than the length specified in the length field.
///
Deserialize the network bytes into the record.
Deserialize the network bytes into the record .
pub fn deserialize(sender: Party, bytes: &[u8]) -> Result<KeRecord, DeserializeError> {
    // The first bit of the first byte is the critical bit.
    let critical = bytes[0] >> 7 == 1;
    // The following 15 bits are the record type number.
    let record_type = u16::from_be_bytes([bytes[0] & 0x7, bytes[1]]);
    // The third and fourth bytes are the body length.
    let length = u16::from_be_bytes([bytes[2], bytes[3]]);
    // The body.
    let body = &bytes[4..4 + usize::from(length)];
    macro_rules! deserialize_body {
        ( $( ($variant:ident, $record:ident) ),* ) => {
            if false {
                // Loop returns ! type.
                loop { }
            } $( else if record_type == $record::record_type() {
                match $record::from_bytes(sender, body) {
                    Ok(record) => KeRecord::$variant(record),
                    Err(error) => return Err(DeserializeError::Parsing(error)),
                }
            } )* else {
                if critical {
                    return Err(DeserializeError::UnknownCriticalRecord);
                } else {
                    return Err(DeserializeError::UnknownNotCriticalRecord);
                }
            }
        };
    }
    let record = deserialize_body!(
        (EndOfMessage, EndOfMessageRecord),
        (NextProtocol, NextProtocolRecord),
        (Error, ErrorRecord),
        (Warning, WarningRecord),
        (AeadAlgorithm, AeadAlgorithmRecord),
        (NewCookie, NewCookieRecord),
        (Server, ServerRecord),
        (Port, PortRecord)
    );
    Ok(record)
}
pub fn deserialize ( sender : Party , bytes : & [ u8 ] ) -> Result < KeRecord , DeserializeError > { // The first bit of the first byte is the critical bit. let critical = bytes [ 0 ] >> 7 == 1 ; // The following 15 bits are the record type number. let record_type = u16 :: from_be_bytes ( [ bytes [ 0 ] & 0x7 , bytes [ 1 ] ] ) ; // The third and fourth bytes are the body length. let length = u16 :: from_be_bytes ( [ bytes [ 2 ] , bytes [ 3 ] ] ) ; // The body. let body = & bytes [ 4 .. 4 + usize :: from ( length ) ] ; macro_rules! deserialize_body { ( $ ( ( $variant : ident $record : ident ) ) * ) => { if false { // Loop returns ! type. loop { } } $ ( else if record_type $record record_type ( ) { match $record from_bytes ( sender body ) { Ok ( record ) KeRecord $variant ( record ) Err ( error ) return Err ( DeserializeError Parsing ( error ) ) } } ) * else { if critical { return Err ( DeserializeError UnknownCriticalRecord ) } else { return Err ( DeserializeError UnknownNotCriticalRecord ) } } } ; } let record = deserialize_body ! ( ( EndOfMessage EndOfMessageRecord ) ( NextProtocol NextProtocolRecord ) ( Error ErrorRecord ) ( Warning WarningRecord ) ( AeadAlgorithm AeadAlgorithmRecord ) ( NewCookie NewCookieRecord ) ( Server ServerRecord ) ( Port PortRecord ) ) ; Ok ( record ) }
Deserialize the network bytes into the record.
Deserialize the network bytes into the record .
sender
Party
bytes
&[u8]
sender
Party
bytes
&[u8]
panics
If slice is shorter than the length specified in the length field.
If slice is shorter than the length specified in the length field .