Struct bz_stream
#[repr(C)]
pub struct bz_stream { pub next_in: *const c_char, pub avail_in: c_uint, pub total_in_lo32: c_uint, pub total_in_hi32: c_uint, pub next_out: *mut c_char, pub avail_out: c_uint, pub total_out_lo32: c_uint, pub total_out_hi32: c_uint, pub state: *mut c_void, pub bzalloc: Option<unsafe extern "C" fn(*mut c_void, c_int, c_int) -> *mut c_void>, pub bzfree: Option<unsafe extern "C" fn(*mut c_void, *mut c_void)>, pub opaque: *mut c_void }
The current stream state.
Custom allocators
The low-level API supports passing in a custom allocator as part of the [bz_stream]:
struct bz_stream {
// ...
pub bzalloc: Option<unsafe extern "C" fn(_: *mut c_void, _: c_int, _: c_int) -> *mut c_void>,
pub bzfree: Option<unsafe extern "C" fn(_: *mut c_void, _: *mut c_void)>,
pub opaque: *mut c_void,
}
When these fields are None (or NULL in C), the initialization functions will try to
put in a default allocator, based on feature flags:
"rust-allocator"uses the rust global allocator"c-allocator"uses an allocator based onmallocandfree
When both configured, "rust-allocator" is preferred. When no default allocator is configured,
the high-level interface will return a BZ_CONFIG_ERROR. The low-level interface (the
functions that take a bz_stream as their argument) return a BZ_PARAM_ERROR, unless the
user set the bzalloc and bzfree fields.
When custom bzalloc and bzfree functions are given, they must adhere to the following contract
to be safe:
- a call
bzalloc(opaque, n, m)must return a pointerpton * mbytes of memory, orNULLif out of memory - a call
bzfree(opaque, p)must free that memory
The strm.opaque value is passed to as the first argument to all calls to bzalloc
and bzfree, but is otherwise ignored by the library.
Fields
next_in: *const c_charavail_in: c_uinttotal_in_lo32: c_uinttotal_in_hi32: c_uintnext_out: *mut c_charavail_out: c_uinttotal_out_lo32: c_uinttotal_out_hi32: c_uintstate: *mut c_voidbzalloc: Option<unsafe extern "C" fn(*mut c_void, c_int, c_int) -> *mut c_void>bzfree: Option<unsafe extern "C" fn(*mut c_void, *mut c_void)>opaque: *mut c_void
Implementations
impl bz_stream
const fn zeroed() -> Self
Auto Trait Implementations
impl !Send for bz_stream
impl !Sync for bz_stream
impl Freeze for bz_stream
impl RefUnwindSafe for bz_stream
impl Unpin for bz_stream
impl UnsafeUnpin for bz_stream
impl UnwindSafe for bz_stream
Blanket Implementations
impl<T> Any for bz_stream
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for bz_stream
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for bz_stream
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for bz_stream
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for bz_stream
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for bz_stream
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for bz_stream
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>