#[repr(C)]pub struct z_stream {Show 14 fields
pub next_in: *const u8,
pub avail_in: u32,
pub total_in: u64,
pub next_out: *mut u8,
pub avail_out: u32,
pub total_out: u64,
pub msg: *mut i8,
pub state: *mut internal_state,
pub zalloc: Option<unsafe extern "C" fn(*mut c_void, u32, u32) -> *mut c_void>,
pub zfree: Option<unsafe extern "C" fn(*mut c_void, *mut c_void)>,
pub opaque: *mut c_void,
pub data_type: i32,
pub adler: u64,
pub reserved: u64,
}Expand description
The current stream state
§Custom allocators
The low-level API supports passing in a custom allocator as part of the z_stream:
struct z_stream {
// ...
zalloc: Option<unsafe extern "C" fn(*mut c_void, c_uint, c_uint) -> *mut c_void>,
zfree: Option<unsafe extern "C" fn(*mut c_void, *mut c_void)>,
opaque: *mut c_void,
}When these fields are None (or NULL in C), the initialization functions use a default allocator,
based on feature flags:
"rust-allocator"uses the rust global allocator"c-allocator"uses an allocator based onmallocandfree
When both are configured, the "rust-allocator" is preferred. When no default allocator is configured,
and custom zalloc and zfree are provided, the initialization functions will return a Z_STREAM_ERROR.
When custom zalloc and zfree functions are given, they must adhere to the following contract
to be safe:
- a call
zalloc(opaque, n, m)must return a pointerpton * mbytes of memory, orNULLif out of memory - a call
zfree(opaque, p)must free that memory
The strm.opaque value is passed to as the first argument to all calls to zalloc
and zfree, but is otherwise ignored by the library.
Fields§
§next_in: *const u8§avail_in: u32§total_in: u64§next_out: *mut u8§avail_out: u32§total_out: u64§msg: *mut i8§state: *mut internal_state§zalloc: Option<unsafe extern "C" fn(*mut c_void, u32, u32) -> *mut c_void>§zfree: Option<unsafe extern "C" fn(*mut c_void, *mut c_void)>§opaque: *mut c_void§data_type: i32§adler: u64§reserved: u64Implementations§
Source§impl z_stream
impl z_stream
pub fn configure_default_c_allocator(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for z_stream
impl RefUnwindSafe for z_stream
impl !Send for z_stream
impl !Sync for z_stream
impl Unpin for z_stream
impl UnwindSafe for z_stream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more