/// Create header bytes to send with payload.
Create header bytes to send with payload.
Create header bytes to send with payload .
fn pack_header(
        payload: Option<&TransportPayload>,
        sender_err: bool,
        heartbeat: bool,
    ) -> Vec<u8> {
        let mut result = Vec::<u8>::new();
        let mut header = TransportHeader {
            version: 0,
            flags: 0,
            reserved: 0,
            payload_length: match payload {
                Some(data) => data.0.len() as u32,
                None => 0,
            },
        };
        if sender_err {
            header.flags = TRANSPORT_FLAGS_SENDER_ERROR;
        }
        if heartbeat {
            header.flags |= TRANSPORT_FLAGS_IS_HEARTBEAT;
        }
        result.append(&mut header.version.to_le_bytes().to_vec());
        result.append(&mut header.flags.to_le_bytes().to_vec());
        result.append(&mut header.reserved.to_le_bytes().to_vec());
        result.append(&mut header.payload_length.to_le_bytes().to_vec());
        assert_eq!(result.len(), TRANSPORT_HEADER_SIZE);
        result
    }
fn pack_header ( payload : Option < & TransportPayload > , sender_err : bool , heartbeat : bool , ) -> Vec < u8 > { let mut result = Vec :: < u8 > :: new ( ) ; let mut header = TransportHeader { version : 0 , flags : 0 , reserved : 0 , payload_length : match payload { Some ( data ) => data . 0 . len ( ) as u32 , None => 0 , } , } ; if sender_err { header . flags = TRANSPORT_FLAGS_SENDER_ERROR ; } if heartbeat { header . flags |= TRANSPORT_FLAGS_IS_HEARTBEAT ; } result . append ( & mut header . version . to_le_bytes ( ) . to_vec ( ) ) ; result . append ( & mut header . flags . to_le_bytes ( ) . to_vec ( ) ) ; result . append ( & mut header . reserved . to_le_bytes ( ) . to_vec ( ) ) ; result . append ( & mut header . payload_length . to_le_bytes ( ) . to_vec ( ) ) ; assert_eq ! ( result len ( ) TRANSPORT_HEADER_SIZE ) ; result }
Create header bytes to send with payload.
Create header bytes to send with payload .
payload
Option<&TransportPayload>
sender_err
bool
heartbeat
bool