pub unsafe extern "C" fn hs_compress_stream(
    stream: *const hs_stream_t,
    buf: *mut c_char,
    buf_space: usize,
    used_space: *mut usize
) -> hs_error_t
Expand description

Creates a compressed representation of the provided stream in the buffer provided. This compressed representation can be converted back into a stream state by using @ref hs_expand_stream() or @ref hs_reset_and_expand_stream(). The size of the compressed representation will be placed into @p used_space.

If there is not sufficient space in the buffer to hold the compressed representation, @ref HS_INSUFFICIENT_SPACE will be returned and @p used_space will be populated with the amount of space required.

Note: this function does not close the provided stream, you may continue to use the stream or to free it with @ref hs_close_stream().

@param stream The stream (as created by @ref hs_open_stream()) to be compressed.

@param buf Buffer to write the compressed representation into. Note: if the call is just being used to determine the amount of space required, it is allowed to pass NULL here and @p buf_space as 0.

@param buf_space The number of bytes in @p buf. If buf_space is too small, the call will fail with @ref HS_INSUFFICIENT_SPACE.

@param used_space Pointer to where the amount of used space will be written to. The used buffer space is always less than or equal to @p buf_space. If the call fails with @ref HS_INSUFFICIENT_SPACE, this pointer will be used to write out the amount of buffer space required.

@return @ref HS_SUCCESS on success, @ref HS_INSUFFICIENT_SPACE if the provided buffer is too small.