Skip to main content

validate_extension_name

Function validate_extension_name 

Source
pub fn validate_extension_name(name: &str) -> Result<(), ExtensionError>
Expand description

Validates the form of a DuckDB extension name.

This is whether DuckDB can load a file of this name. Whether a community extension may take the name is validate_community_extension_name, which also refuses the names DuckDB itself uses.

§Rules

  • Must not be empty
  • Must contain only lowercase ASCII letters (a-z), digits (0-9), or underscores (_) — no hyphens: DuckDB derives the entry-point symbol <name>_init_c_api from the name (see the module docs)
  • Must start with a letter
  • Must not exceed 64 characters

§Errors

Returns ExtensionError describing the first rule violation found.

§Example

use quack_rs::validate::validate_extension_name;

assert!(validate_extension_name("my_extension").is_ok());
assert!(validate_extension_name("my_ext_2").is_ok());
assert!(validate_extension_name("my-ext").is_err()); // no C symbol can hold '-'
assert!(validate_extension_name("").is_err());
assert!(validate_extension_name("MyExtension").is_err());
assert!(validate_extension_name("my extension").is_err());
assert!(validate_extension_name("123start").is_err());