brotli_decompressor/ffi/
interface.rs
1use ::BrotliResult;
2#[allow(non_camel_case_types)]
3#[repr(u8)]
4pub enum c_void{
5 _Nothing = 0,
6}
7
8#[repr(C)]
9#[allow(dead_code)]
10pub enum BrotliDecoderParameter {
11 BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION = 0,
12 BROTLI_DECODER_PARAM_LARGE_WINDOW = 1,
13}
14
15
16#[repr(C)]
17pub enum BrotliDecoderResult {
18 BROTLI_DECODER_RESULT_ERROR = 0,
19 BROTLI_DECODER_RESULT_SUCCESS = 1,
20 BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT = 2,
21 BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT = 3,
22}
23
24
25impl From<BrotliResult> for BrotliDecoderResult {
26 fn from(r: BrotliResult) -> Self {
27 match r {
28 BrotliResult::ResultSuccess => BrotliDecoderResult::BROTLI_DECODER_RESULT_SUCCESS,
29 BrotliResult::ResultFailure => BrotliDecoderResult::BROTLI_DECODER_RESULT_ERROR,
30 BrotliResult::NeedsMoreInput => BrotliDecoderResult::BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT ,
31 BrotliResult::NeedsMoreOutput => BrotliDecoderResult::BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT ,
32 }
33 }
34}
35pub type brotli_alloc_func = Option<extern "C" fn(data: *mut c_void, size: usize) -> *mut c_void>;
36
37pub type brotli_free_func = Option<extern "C" fn(data: *mut c_void, ptr: *mut c_void) -> ()>;
38
39
40#[repr(C)]
41#[derive(Clone)]
42pub struct CAllocator {
43 pub alloc_func: brotli_alloc_func,
44 pub free_func: brotli_free_func,
45 pub opaque: *mut c_void,
46}
47
48unsafe impl Send for CAllocator {
49}