[][src]Function gifski::c_api::gifski_set_write_callback

#[no_mangle]pub unsafe extern "C" fn gifski_set_write_callback(
    handle: *const GifskiHandle,
    cb: Option<unsafe extern "C" fn(_: usize, _: *const u8, _: *mut c_void) -> c_int>,
    user_data: *mut c_void
) -> GifskiError

Start writing via callback (any buffer, file, whatever you want). This has to be called before any frames are added. This call will not block.

The callback function receives 3 arguments:

  • size of the buffer to write, in bytes. IT MAY BE ZERO (when it's zero, either do nothing, or flush internal buffers if necessary).
  • pointer to the buffer.
  • context pointer to arbitary user data, same as passed in to this function.

The callback should return 0 (GIFSKI_OK) on success, and non-zero on error.

The callback function must be thread-safe. It must remain valid at all times, until gifski_finish completes.

Returns 0 (GIFSKI_OK) on success, and non-0 GIFSKI_* constant on error.