Skip to main content

Module naming

Module naming 

Source
Expand description

Canonical naming policy for everything alef generates.

This module is a facade. It owns no logic; it declares the submodules and re-exports their public surface so that crate::codegen::naming::<item> keeps resolving for every backend.

The split follows the four name surfaces the project treats as separate — a public host identifier, a serde wire name, an internal generated Rust name, and an ABI/native symbol — rather than following line count. Each surface answers to a different authority (a host language’s grammar, serde’s derive, rustc, the C linker), so each gets a module that can change for exactly one of those reasons:

  • surfaces — the vocabulary (NameSurface, IdentifierContext, PublicIdentifierKind) plus collision detection over a generated-name scope.
  • wire — serde wire names. Never a host identifier.
  • host — public host-language identifiers, the names a binding’s consumer types.
  • symbols — internal Rust identifiers and C ABI / native symbols.
  • identifiers — identifier legality and escaping, applied by every surface above.
  • languages — the per-language spelling choice (Go’s URL, C#’s Json, …).
  • case — language-agnostic mechanical case conversion, the primitives the rest compose.
  • ts_property_key — rendering a wire name into TypeScript key position. ~keep

Re-exports§

pub use case::pascal_to_camel;
pub use case::pascal_to_pascal;
pub use case::pascal_to_screaming_snake;
pub use case::pascal_to_snake;
pub use case::to_class_name;
pub use case::to_constant_name;
pub use case::underscore_camel_case;
pub use host::public_field_name;
pub use host::public_host_identifier;
pub use host::qualified_type_path;
pub use identifiers::dart_tuple_field_identifier;
pub use identifiers::dart_type_identifier;
pub use identifiers::dart_value_identifier;
pub use identifiers::escape_identifier;
pub use identifiers::escape_identifier_for;
pub use identifiers::is_valid_identifier;
pub use identifiers::is_valid_identifier_for;
pub use identifiers::validate_identifier;
pub use languages::csharp_type_name;
pub use languages::csharp_variant_name;
pub use languages::csharp_wrapper_class_name;
pub use languages::go_error_type_name;
pub use languages::go_free_function_name;
pub use languages::go_package_name_from_module;
pub use languages::go_param_name;
pub use languages::go_type_name;
pub use languages::go_variant_name;
pub use languages::kotlin_android_wrapper_object_name;
pub use languages::node_type_name;
pub use languages::to_csharp_name;
pub use languages::to_elixir_name;
pub use languages::to_go_name;
pub use languages::to_java_name;
pub use languages::to_node_name;
pub use languages::to_php_name;
pub use languages::to_python_name;
pub use languages::to_ruby_name;
pub use surfaces::IdentifierContext;
pub use surfaces::NameCollision;
pub use surfaces::NameError;
pub use surfaces::NameSurface;
pub use surfaces::PublicIdentifierKind;
pub use surfaces::detect_name_collisions;
pub use symbols::abi_symbol;
pub use symbols::abi_symbol_from_components;
pub use symbols::ffi_builtin_error_code_prefix;
pub use symbols::ffi_error_code_variant_name;
pub use symbols::internal_rust_identifier;
pub use symbols::to_c_name;
pub use wire::apply_serde_rename_all;
pub use wire::field_uses_duration_map_wire;
pub use wire::serde_wire_name;
pub use wire::wire_field_name;
pub use wire::wire_field_name_camel;
pub use wire::wire_variant_value;

Modules§

case
Language-agnostic mechanical case conversion.
host
The public host-language identifier surface: the names a consumer of a generated binding actually types.
identifiers
Identifier legality and escaping: whether a name can be spelled at all in a target language, and how to make it spellable.
languages
Per-language spellings of a public host identifier, and the language-specific initialism policy each one applies.
surfaces
The name-surface vocabulary shared by every naming helper, plus collision detection over a generated-name scope.
symbols
The two name surfaces no host-language consumer ever reads: internal generated Rust identifiers, and C ABI / native symbols.
ts_property_key
Rendering a serde WIRE name into the key position of a TypeScript object type member.
wire
The serde wire-name surface: JSON/serialization names, never host-language identifiers.