Skip to main content

Module hash

Module hash 

Source
Expand description

HashPlugin trait — the Rust-side counterpart of the hash v0 wire protocol.

Plugin authors implement this trait on their hash state type, then apply #[plugin_interface(name = "hash", version = 0)] to the impl block. The macro emits the eight canonical cfmp_hash_* FFI symbols, one per trait method.

Method → symbol mapping (see crates/confium-core/src/ffi/hash.rs for the loader-side wire types):

trait methodFFI symbolpurpose
HashPlugin::create_with_optscfmp_hash_createconstruct a new instance
HashPlugin::output_sizecfmp_hash_output_sizeoutput length in bytes
HashPlugin::block_sizecfmp_hash_block_sizeinternal block size in bytes
HashPlugin::updatecfmp_hash_updateabsorb input bytes
HashPlugin::resetcfmp_hash_resetreset to initial state
HashPlugin::try_clonecfmp_hash_cloneduplicate the state
HashPlugin::finalizecfmp_hash_finalizeemit digest into caller buffer
Dropcfmp_hash_destroyreclaim the boxed state

Traits§

HashPlugin
Trait implemented by hash plugins. The macro-generated cfmp_hash_create calls HashPlugin::create_with_opts; all other symbols dispatch through OpaqueHandle::<Self>::borrow_raw and the corresponding trait method.

Functions§

create_simple
Trivial constructor entry point for plugin authors who don’t need opts. Wraps HashPlugin::create_with_opts with None.
default_block_size
Default block_size implementation for hash plugins that don’t have a meaningful block size. Returns 64, the common block size for SHA-2 family hashes.