#[repr(C)]pub struct ZL_MaterializerDesc_s {
pub materializeFn: Option<unsafe extern "C" fn(matCtx: *mut ZL_Materializer, params: *const ZL_LocalParams) -> ZL_Result_ZL_VoidPtr>,
pub dematerializeFn: Option<unsafe extern "C" fn(matCtx: *mut ZL_Materializer, materialized: *mut c_void)>,
pub paramId: c_int,
pub opaque: *const c_void,
}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.
Fields§
§materializeFn: Option<unsafe extern "C" fn(matCtx: *mut ZL_Materializer, params: *const ZL_LocalParams) -> ZL_Result_ZL_VoidPtr>@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(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.
paramId: c_intThe paramId to use for the materialized param. If there is an existing param that uses this paramId, the registration will fail.
opaque: *const c_voidOptionally 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.
Trait Implementations§
Source§impl Clone for ZL_MaterializerDesc_s
impl Clone for ZL_MaterializerDesc_s
Source§fn clone(&self) -> ZL_MaterializerDesc_s
fn clone(&self) -> ZL_MaterializerDesc_s
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more