Function hyper::ffi::hyper_io_set_read
source · #[no_mangle]
pub extern "C" fn hyper_io_set_read(
io: *mut hyper_io,
func: extern "C" fn(_: *mut c_void, _: *mut hyper_context<'_>, _: *mut u8, _: size_t) -> size_t
)
ffi
and hyper_unstable_ffi
only.Expand description
Set the read function for this IO transport.
Data that is read from the transport should be put in the buf
pointer,
up to buf_len
bytes. The number of bytes read should be the return value.
It is undefined behavior to try to access the bytes in the buf
pointer,
unless you have already written them yourself. It is also undefined behavior
to return that more bytes have been written than actually set on the buf
.
If there is no data currently available, the callback should create a
hyper_waker
from its hyper_context
argument and register the waker
with whatever polling mechanism is used to signal when data is available
later on. The return value should be HYPER_IO_PENDING
. See the
documentation for hyper_waker
.
If there is an irrecoverable error reading data, then HYPER_IO_ERROR
should be the return value.