#[repr(C)]pub struct z_stream {Show 14 fields
pub next_in: *const Bytef,
pub avail_in: uInt,
pub total_in: c_ulong,
pub next_out: *mut Bytef,
pub avail_out: uInt,
pub total_out: c_ulong,
pub msg: *mut c_char,
pub state: *mut internal_state,
pub zalloc: Option<alloc_func>,
pub zfree: Option<free_func>,
pub opaque: voidpf,
pub data_type: c_int,
pub adler: c_ulong,
pub reserved: uLong,
}
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 onmalloc
andfree
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 pointerp
ton * m
bytes of memory, orNULL
if 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 Bytef
§avail_in: uInt
§total_in: c_ulong
§next_out: *mut Bytef
§avail_out: uInt
§total_out: c_ulong
§msg: *mut c_char
§state: *mut internal_state
§zalloc: Option<alloc_func>
§zfree: Option<free_func>
§opaque: voidpf
§data_type: c_int
§adler: c_ulong
§reserved: uLong
Implementations§
Source§impl z_stream
impl z_stream
pub fn configure_default_rust_allocator(&mut self)
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