Skip to main content

CreateFn

Type Alias CreateFn 

Source
pub type CreateFn = unsafe extern "C" fn(config_json: *const u8, config_len: usize) -> *mut Box<dyn Plugin>;
Expand description

Type signature for the plugin creation function exported by cdylib plugins.

The function receives a UTF-8 JSON configuration string (pointer + length) and returns a double-boxed Plugin trait object. The outer Box yields a thin pointer (C-ABI safe); the inner Box<dyn Plugin> is a fat pointer stored on the heap.

§Arguments

  • config_json — pointer to a UTF-8 JSON string, or null for default config
  • config_len — length of the config string in bytes (0 if null)

§Returns

A thin pointer to a heap-allocated Box<dyn Plugin>. The caller takes ownership and must free it via DestroyFn or drop(Box::from_raw(ptr)).

§Safety

  • If config_json is non-null, it must be valid for reads of config_len bytes
  • The returned pointer must not be null