Skip to main content

InitFn

Type Alias InitFn 

Source
pub type InitFn = unsafe extern "C" fn(error_msg_ptr: *mut *mut u8, error_msg_len: *mut usize) -> i32;
Expand description

Function signature for plugin initialization

Called by the framework at the end of handle_initialize, after:

  • Plugin library is loaded
  • Configuration is set (via configure function if present)
  • But before any tools are registered or called

The plugin should use this to:

  • Validate configuration
  • Initialize resources (database connections, caches, etc.)
  • Perform any expensive setup operations
  • Report initialization errors

§Parameters

  • error_msg_ptr: Output pointer for error message (on failure)
  • error_msg_len: Output length of error message (on failure)

§Returns

  • 0 on success
  • Non-zero error code on failure

If initialization fails, the plugin should allocate an error message, write the pointer and length to the output parameters, and return non-zero. The framework will call free_string to deallocate the error message.