Skip to main content

moq_consume_json

Function moq_consume_json 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn moq_consume_json( broadcast: u32, name: *const c_char, name_len: usize, config: *const moq_json_config, on_value: Option<extern "C" fn(user_data: *mut c_void, value: i32)>, user_data: *mut c_void, ) -> i32
Expand description

Subscribe to a JSON snapshot track (lossy latest-value) by name.

on_value is called with a positive value ID for each new latest value; a consumer that falls behind collapses the backlog and only sees the newest. It is called exactly once more with a terminal 0 (track ended / closed) or a negative error, after which user_data is never touched again, so release it there. Read each value with moq_consume_json_value and release it with moq_consume_json_value_close. Pass the same compression the producer used.

Returns a non-zero handle to the task on success, or a negative code on failure.

ยงSafety

  • The caller must ensure name is a valid pointer to name_len bytes and config a valid pointer.
  • The caller must keep user_data valid until the terminal (<= 0) on_value callback.