Skip to main content

ZL_MaterializerDesc

Type Alias ZL_MaterializerDesc 

Source
pub type ZL_MaterializerDesc = ZL_MaterializerDesc_s;
Expand description

@brief Descriptor for materializing and dematerializing local params

This structure defines functions to materialize an in-memory object from local parameters and to dematerialize (free) that object.

Materialized objects are available as a @ref ZL_RefParam via the typical local params access methods. Specify the retrieval key with the paramId field.

Aliased Type§

#[repr(C)]
pub struct ZL_MaterializerDesc { pub materializeFn: Option<unsafe extern "C" fn(*mut ZL_Materializer_s, *const ZL_LocalParams) -> ZL_Result_ZL_VoidPtr_u>, pub dematerializeFn: Option<unsafe extern "C" fn(*mut ZL_Materializer_s, *mut c_void)>, pub paramId: i32, pub opaque: *const c_void, }

Fields§

§materializeFn: Option<unsafe extern "C" fn(*mut ZL_Materializer_s, *const ZL_LocalParams) -> ZL_Result_ZL_VoidPtr_u>

@brief A custom function that materializes an in-memory object from a provided @p params object.

This function may arbitrarily use none, any, or all of the provided local params to generate the materialized object, but the generation MUST be deterministic and hermetic. In particular, materialization shall not depend on variables other than the provided @ref ZL_LocalParams object.

Materialized object lifetimes will be managed by the @ref ZL_Compressor on which the node is registered/parameterized. Objects will be materialized around the time of node registration/parameterization and will remain allocated for the lifetime of the associated @ref ZL_Compressor.

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.

The @ref ZL_Compressor may arbitrarily share the same materialized object between multiple nodes with the same @p params and the @ref ZL_CCtx may provide concurrent access to materialized objects. 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 associated with the @ref ZL_Compressor. The materialization function may use this to request managed memory from the ZL_Compressor as an alternative to managing allocations itself and via the dematerializeFn. @param params A pointer to the local params object to materialize. The provided params have no lifetime guarantees past the invocation of this function. You may not hold references into the params object 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(*mut ZL_Materializer_s, *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.

§paramId: i32

The paramId to use for the materialized param. If there is an existing param that uses this paramId, the registration will fail.

§opaque: *const c_void

Optionally an opaque pointer that can be queried with ZL_Materializer_getOpaquePtr(). OpenZL does not take ownership of this pointer. If lifetime extension is needed, it should be managed by the ZL_OpaquePtr in the outer ZL_MIEncoderDesc.