Skip to main content

ZL_MaterializerDesc2

Struct ZL_MaterializerDesc2 

Source
#[repr(C)]
pub struct ZL_MaterializerDesc2 { pub materializeFn: Option<unsafe extern "C" fn(matCtx: *mut ZL_Materializer, src: *const c_void, srcSize: usize) -> ZL_Result_ZL_VoidPtr>, pub dematerializeFn: Option<unsafe extern "C" fn(matCtx: *mut ZL_Materializer, materialized: *mut c_void)>, pub opaque: ZL_OpaquePtr, }
Expand description

@brief Descriptor for materializing and dematerializing resource objects (dicts and MParams).

Defines functions to create an in-memory object from a raw source buffer (materializeFn) and to free that object (dematerializeFn). Used for both dictionary objects (required at compression and decompression) and MParam objects (compression-only). Note that the registration APIs allow for different materializers for compression-time and decompression-time dict materialization.

Fields§

§materializeFn: Option<unsafe extern "C" fn(matCtx: *mut ZL_Materializer, src: *const c_void, srcSize: usize) -> ZL_Result_ZL_VoidPtr>

@brief A custom function that materializes an in-memory object from a provided @p src buffer. Separate function interfaces are provided for compression-time and decompression-time materialization. These can be the same function or different functions, depending on the specific codec implementation.

The generation MUST be deterministic and hermetic. Materialization shall not depend on variables other than the provided @p src buffer.

Materialized object lifetimes will be managed by the @ref ZL_DictLoader or @ref ZL_Compressor on which the materialization scheme is registered.

Do NOT rely on the materialization function being called at any specific time to do side-effect work. Doing so will result in undefined behavior.

DO NOT attempt to modify the materialized object after creation, either directly or via API getters.

@param matCtx A pointer to a materializer context object. The materialization function may use this to request managed memory as an alternative to managing allocations itself and via the dematerializeFn. @param src A pointer to the buffer from which to materialize. The provided buffer has no lifetime guarantees past the invocation of this function. You may not hold references into @p src in the materialized object.

@returns A ZL_RESULT containing a pointer to the materialized object on success, or an error. Returning NULL as a valid result (when there’s nothing to materialize) should be wrapped in ZL_WRAP_VALUE(NULL). Ensure the function declares a result scope with ZL_RESULT_DECLARE_SCOPE or you will get a compiler error.

§dematerializeFn: Option<unsafe extern "C" fn(matCtx: *mut ZL_Materializer, materialized: *mut c_void)>

@brief A custom function that destructs a materialized object.

You should use this to deallocate all non-arena memory and free any held resources. As a convenience, if there are no resources or memory to free, you may use ZL_NOOP_DEMATERIALIZE as a placeholder.

§opaque: ZL_OpaquePtr

Optionally an opaque pointer that can be queried with ZL_Materializer_getOpaquePtr(). OpenZL unconditionally takes ownership of this pointer, even if registration fails, and it lives for the lifetime of the owning compressor/dict store.

Trait Implementations§

Source§

impl Clone for ZL_MaterializerDesc2

Source§

fn clone(&self) -> ZL_MaterializerDesc2

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ZL_MaterializerDesc2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for ZL_MaterializerDesc2

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.