Function hyper::ffi::hyper_body_foreach

source ·
#[no_mangle]
pub extern "C" fn hyper_body_foreach(
    body: *mut hyper_body,
    func: extern "C" fn(_: *mut c_void, _: *const hyper_buf) -> c_int,
    userdata: *mut c_void
) -> *mut hyper_task
Available on crate feature ffi and hyper_unstable_ffi only.
Expand description

Creates a task to execute the callback with each body chunk received.

To avoid a memory leak, the task must eventually be consumed by hyper_task_free, or taken ownership of by hyper_executor_push without subsequently being given back by hyper_executor_poll.

The hyper_buf pointer is only a borrowed reference. It cannot live outside the execution of the callback. You must make a copy of the bytes to retain them.

The callback should return HYPER_ITER_CONTINUE to continue iterating chunks as they are received, or HYPER_ITER_BREAK to cancel. Each invocation of the callback must consume all the bytes it is provided. There is no mechanism to signal to Hyper that only a subset of bytes were consumed.

This will consume the hyper_body *, you shouldn’t use it anymore or free it.