Skip to main content

pamoja_message_new

Function pamoja_message_new 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_message_new( topic: *const c_char, payload: *const u8, payload_len: usize, ) -> *mut PamojaMessage
Expand description

Builds a message for a host’s recv callback to deliver.

§Arguments

  • topic - the topic the message arrived on, as null-terminated UTF-8.
  • payload - the payload bytes, or null when payload_len is 0.
  • payload_len - the length of payload.

§Returns

A message the receiving side owns once it is stored in out_message; release it with pamoja_message_free only if it is not handed over. Null if topic is null or not UTF-8, or payload is null with a nonzero length.

§Safety

topic must be a valid null-terminated string and payload must point to at least payload_len readable bytes or be null when that length is 0.