Attribute Macro sqlite3_ext::sqlite3_ext_init
source · #[sqlite3_ext_init]Expand description
Declare the entry point to an extension.
This method generates an extern "C" function suitable for use by SQLite’s loadable
extension feature. An export name can optionally be provided. Consult the SQLite
documentation for information
about naming the exported method, but generally you can use sqlite3_ext_main to
automatically name the export correctly.
If the persistent keyword is included in the attribute, the extension will be loaded permanently. See the SQLite documentation for more information.
Example
Specifying a nonstandard entry point name:
use sqlite3_ext::*;
#[sqlite3_ext_init(export = nonstandard_entry_point, persistent)]
fn init(db: &Connection) -> Result<()> {
Ok(())
}This extension could be loaded from SQLite:
SELECT load_extension('path/to/extension', 'nonstandard_entry_point');
Implementation
This macro renames the original Rust function and instead creates an
sqlite3_ext::Extension object in its place. Because Extension dereferences to the
original function, you generally won’t notice this change. This behavior allows you to use
the original identifier to pass the auto extension methods.