/// Encode a slice as an opaque byte sequence.
Encode a slice as an opaque byte sequence.
Encode a slice as an opaque byte sequence .
pub unsafe fn tibrv_encode_opaque<'a, T: Copy>(
    slice: &'a [T],
    name: Option<&str>,
    id: Option<u32>,
) -> MsgField {
    must_name!(name, id);
    let name_cstr = name.and_then(|s| Some(CString::new(s).unwrap()));
    let ptr = name_cstr.as_ref().map_or(std::ptr::null(), |s| s.as_ptr());
    MsgField {
        name: name_cstr,
        inner: tibrvMsgField {
            name: ptr,
            size: std::mem::size_of_val(slice) as tibrv_u32,
            count: 1 as tibrv_u32,
            data: tibrvLocalData {
                buf: slice.as_ptr() as *const c_void,
            },
            id: id.unwrap_or(0) as tibrv_u16,
            type_: TIBRVMSG_OPAQUE as tibrv_u8,
        },
    }
}
pub unsafe fn tibrv_encode_opaque < ' a , T : Copy > ( slice : & ' a [ T ] , name : Option < & str > , id : Option < u32 > , ) -> MsgField { must_name ! ( name id ) ; let name_cstr = name . and_then ( | s | Some ( CString :: new ( s ) . unwrap ( ) ) ) ; let ptr = name_cstr . as_ref ( ) . map_or ( std :: ptr :: null ( ) , | s | s . as_ptr ( ) ) ; MsgField { name : name_cstr , inner : tibrvMsgField { name : ptr , size : std :: mem :: size_of_val ( slice ) as tibrv_u32 , count : 1 as tibrv_u32 , data : tibrvLocalData { buf : slice . as_ptr ( ) as * const c_void , } , id : id . unwrap_or ( 0 ) as tibrv_u16 , type_ : TIBRVMSG_OPAQUE as tibrv_u8 , } , } }
Encode a slice as an opaque byte sequence.
Encode a slice as an opaque byte sequence .
slice
&'a [T]
name
Option<&str>
id
Option<u32>