[][src]Function compu_brotli_sys::BrotliEncoderCompressStream

pub unsafe extern "C" fn BrotliEncoderCompressStream(
    state: *mut BrotliEncoderState,
    op: BrotliEncoderOperation,
    available_in: *mut usize,
    next_in: *mut *const u8,
    available_out: *mut usize,
    next_out: *mut *mut u8,
    total_out: *mut usize
) -> c_int

Compresses input stream to output stream.

The values @p *available_in and @p *available_out must specify the number of bytes addressable at @p *next_in and @p *next_out respectively. When @p *available_out is @c 0, @p next_out is allowed to be @c NULL.

After each call, @p *available_in will be decremented by the amount of input bytes consumed, and the @p *next_in pointer will be incremented by that amount. Similarly, @p *available_out will be decremented by the amount of output bytes written, and the @p *next_out pointer will be incremented by that amount.

@p total_out, if it is not a null-pointer, will be set to the number of bytes compressed since the last @p state initialization.

Internally workflow consists of 3 tasks: -# (optionally) copy input data to internal buffer -# actually compress data and (optionally) store it to internal buffer -# (optionally) copy compressed bytes from internal buffer to output stream

Whenever all 3 tasks can't move forward anymore, or error occurs, this method returns the control flow to caller.

@p op is used to perform flush, finish the stream, or inject metadata block. See ::BrotliEncoderOperation for more information.

Flushing the stream means forcing encoding of all input passed to encoder and completing the current output block, so it could be fully decoded by stream decoder. To perform flush set @p op to ::BROTLI_OPERATION_FLUSH. Under some circumstances (e.g. lack of output stream capacity) this operation would require several calls to ::BrotliEncoderCompressStream. The method must be called again until both input stream is depleted and encoder has no more output (see ::BrotliEncoderHasMoreOutput) after the method is called.

Finishing the stream means encoding of all input passed to encoder and adding specific "final" marks, so stream decoder could determine that stream is complete. To perform finish set @p op to ::BROTLI_OPERATION_FINISH. Under some circumstances (e.g. lack of output stream capacity) this operation would require several calls to ::BrotliEncoderCompressStream. The method must be called again until both input stream is depleted and encoder has no more output (see ::BrotliEncoderHasMoreOutput) after the method is called.

@warning When flushing and finishing, @p op should not change until operation is complete; input stream should not be swapped, reduced or extended as well.

@param state encoder instance @param op requested operation @param[in, out] available_in @b in: amount of available input; \n @b out: amount of unused input @param[in, out] next_in pointer to the next input byte @param[in, out] available_out @b in: length of output buffer; \n @b out: remaining size of output buffer @param[in, out] next_out compressed output buffer cursor; can be @c NULL if @p available_out is @c 0 @param[out] total_out number of bytes produced so far; can be @c NULL @returns ::BROTLI_FALSE if there was an error @returns ::BROTLI_TRUE otherwise