Skip to main content

ResolvedCrateConfig

Struct ResolvedCrateConfig 

Source
pub struct ResolvedCrateConfig {
Show 59 fields pub name: String, pub sources: Vec<PathBuf>, pub source_crates: Vec<SourceCrate>, pub version_from: String, pub core_import: Option<String>, pub workspace_root: Option<PathBuf>, pub skip_core_import: bool, pub error_type: Option<String>, pub error_constructor: Option<String>, pub features: Vec<String>, pub path_mappings: HashMap<String, String>, pub extra_dependencies: HashMap<String, Value>, pub auto_path_mappings: bool, pub languages: Vec<Language>, pub python: Option<PythonConfig>, pub node: Option<NodeConfig>, pub ruby: Option<RubyConfig>, pub php: Option<PhpConfig>, pub elixir: Option<ElixirConfig>, pub wasm: Option<WasmConfig>, pub ffi: Option<FfiConfig>, pub go: Option<GoConfig>, pub java: Option<JavaConfig>, pub dart: Option<DartConfig>, pub kotlin: Option<KotlinConfig>, pub kotlin_android: Option<KotlinAndroidConfig>, pub jni: Option<JniConfig>, pub swift: Option<SwiftConfig>, pub gleam: Option<GleamConfig>, pub csharp: Option<CSharpConfig>, pub r: Option<RConfig>, pub zig: Option<ZigConfig>, pub exclude: ExcludeConfig, pub include: IncludeConfig, pub output_paths: HashMap<String, PathBuf>, pub explicit_output: OutputConfig, pub lint: HashMap<String, LintConfig>, pub test: HashMap<String, TestConfig>, pub setup: HashMap<String, SetupConfig>, pub update: HashMap<String, UpdateConfig>, pub clean: HashMap<String, CleanConfig>, pub build_commands: HashMap<String, BuildCommandConfig>, pub generate: GenerateConfig, pub generate_overrides: HashMap<String, GenerateConfig>, pub format: FormatConfig, pub format_overrides: HashMap<String, FormatConfig>, pub dto: DtoConfig, pub tools: ToolsConfig, pub opaque_types: HashMap<String, String>, pub sync: Option<SyncConfig>, pub publish: Option<PublishConfig>, pub e2e: Option<E2eConfig>, pub adapters: Vec<AdapterConfig>, pub trait_bridges: Vec<TraitBridgeConfig>, pub scaffold: Option<ScaffoldConfig>, pub readme: Option<ReadmeConfig>, pub custom_files: HashMap<String, Vec<PathBuf>>, pub custom_modules: CustomModulesConfig, pub custom_registrations: CustomRegistrationsConfig,
}
Expand description

Fully-resolved configuration for one crate.

Backends consume &ResolvedCrateConfig; they should not need to look at the workspace defaults directly. Anything a backend reads has already been merged in by crate::config::NewAlefConfig::resolve.

output_paths is precomputed: for every language this crate targets, the map holds the resolved output directory (with {crate} and {lang} placeholders substituted).

Fields§

§name: String§sources: Vec<PathBuf>§source_crates: Vec<SourceCrate>§version_from: String§core_import: Option<String>§workspace_root: Option<PathBuf>§skip_core_import: bool§error_type: Option<String>§error_constructor: Option<String>§features: Vec<String>§path_mappings: HashMap<String, String>§extra_dependencies: HashMap<String, Value>§auto_path_mappings: bool§languages: Vec<Language>§python: Option<PythonConfig>§node: Option<NodeConfig>§ruby: Option<RubyConfig>§php: Option<PhpConfig>§elixir: Option<ElixirConfig>§wasm: Option<WasmConfig>§ffi: Option<FfiConfig>§go: Option<GoConfig>§java: Option<JavaConfig>§dart: Option<DartConfig>§kotlin: Option<KotlinConfig>§kotlin_android: Option<KotlinAndroidConfig>§jni: Option<JniConfig>§swift: Option<SwiftConfig>§gleam: Option<GleamConfig>§csharp: Option<CSharpConfig>§r: Option<RConfig>§zig: Option<ZigConfig>§exclude: ExcludeConfig§include: IncludeConfig§output_paths: HashMap<String, PathBuf>

Resolved output directory per language code ("python"packages/python/spikard/). Only contains entries for languages this crate actually targets.

§explicit_output: OutputConfig

Raw user-supplied per-language output paths from [crates.output].

Distinct from Self::output_paths: this preserves the original (possibly None) value so methods that need to distinguish “user explicitly set this path” from “template-derived” can do so. Used by Self::ffi_lib_name and any other consumer that derives identifiers from the user-supplied path.

§lint: HashMap<String, LintConfig>§test: HashMap<String, TestConfig>§setup: HashMap<String, SetupConfig>§update: HashMap<String, UpdateConfig>§clean: HashMap<String, CleanConfig>§build_commands: HashMap<String, BuildCommandConfig>§generate: GenerateConfig§generate_overrides: HashMap<String, GenerateConfig>§format: FormatConfig§format_overrides: HashMap<String, FormatConfig>§dto: DtoConfig§tools: ToolsConfig§opaque_types: HashMap<String, String>§sync: Option<SyncConfig>§publish: Option<PublishConfig>§e2e: Option<E2eConfig>§adapters: Vec<AdapterConfig>§trait_bridges: Vec<TraitBridgeConfig>§scaffold: Option<ScaffoldConfig>§readme: Option<ReadmeConfig>§custom_files: HashMap<String, Vec<PathBuf>>§custom_modules: CustomModulesConfig§custom_registrations: CustomRegistrationsConfig

Implementations§

Source§

impl ResolvedCrateConfig

Source

pub fn jni_lib_name(&self) -> String

Get the JNI native library name used by Android JNI Bridge objects.

Returns <ffi_prefix>_jni, parallel to Self::ffi_lib_name. This is the library name passed to System.loadLibrary(...) in the emitted Kotlin Bridge object when KotlinFfiStyle::Jni is active.

Source

pub fn kotlin_ffi_style(&self) -> KotlinFfiStyle

Returns the configured Kotlin FFI emission style.

Reads [crates.kotlin] ffi_style; defaults to KotlinFfiStyle::Panama. The alef-backend-kotlin-android backend overrides this to Jni unconditionally via Self::with_kotlin_ffi_style.

Source

pub fn with_kotlin_ffi_style(self, style: KotlinFfiStyle) -> Self

Return a clone of this config with the Kotlin FFI style forced to style.

Used by the Android backend so all downstream emitters see Jni mode regardless of what the user wrote in [crates.kotlin] ffi_style.

Source

pub fn ffi_prefix(&self) -> String

Get the FFI prefix (e.g., "kreuzberg"). Used by FFI, Go, Java, C# backends.

Returns [ffi] prefix if set, otherwise derives from the crate name by replacing hyphens with underscores.

Source

pub fn ffi_lib_name(&self) -> String

Get the FFI native library name (for Go cgo, Java Panama, C# P/Invoke).

Resolution order:

  1. [ffi] lib_name explicit override
  2. Directory name of the user-supplied [crates.output] ffi path with hyphens replaced by underscores (e.g. crates/html-to-markdown-ffi/src/html_to_markdown_ffi). Walks components from the end and skips src/lib/include to find the crate directory.
  3. {ffi_prefix}_ffi fallback
Source

pub fn ffi_header_name(&self) -> String

Get the FFI header name.

Returns [ffi] header_name if set, otherwise "{ffi_prefix}.h".

Source

pub fn ffi_plugin_error_constructor(&self) -> Option<String>

Resolve the Rust expression used by FFI plugin shims (plugin_impl_initialize, plugin_impl_shutdown) to construct an error value from a runtime String named msg.

Returns [ffi] plugin_error_constructor verbatim when set; otherwise None so callers can fall back to a generic constructor that doesn’t depend on a specific error variant shape.

Source

pub fn ffi_crate_path(&self) -> String

Get the relative path to the FFI crate from the e2e test directory.

Used by C e2e tests to locate the compiled FFI library when building against a local checkout rather than a downloaded release.

Resolution order:

  1. Directory name of the user-supplied [crates.output] ffi path, skipping trailing src/lib/include components, prefixed with ../../ so the path resolves from e2e/c/ back to the repo root. E.g. crates/my-lib-ffi/src/../../crates/my-lib-ffi.
  2. ../../crates/{name}-ffi fallback derived from the crate name.
Source

pub fn wasm_crate_path(&self) -> String

Get the relative path to the WASM crate’s pkg/ directory from the e2e test directory.

Used by WASM e2e tests to import the wasm-pack build output when working against a local checkout rather than a published npm package.

Resolution order:

  1. Directory name of the user-supplied [crates.output] wasm path, skipping trailing src/lib/include components, prefixed with ../../ and suffixed with /pkg. E.g. crates/my-lib-wasm/src/../../crates/my-lib-wasm/pkg.
  2. ../../crates/{name}-wasm/pkg fallback derived from the crate name.
Source§

impl ResolvedCrateConfig

Source

pub fn resolve_field_name( &self, lang: Language, type_name: &str, field_name: &str, ) -> Option<String>

Resolve the binding field name for a given language, type, and field.

Resolution order (highest to lowest priority):

  1. Per-language rename_fields map for the key "TypeName.field_name".
  2. Automatic keyword escaping: if the field name is a reserved keyword in the target language, append _ (e.g. classclass_).
  3. Original field name unchanged.

Returns Some(escaped_name) when the field needs renaming, None when the original name can be used as-is. Call sites that always need a String should use resolve_field_name(...).unwrap_or_else(|| field_name.to_string()).

Source

pub fn serde_rename_all_for_language(&self, lang: Language) -> String

Get the effective serde rename_all strategy for a given language.

Resolution order:

  1. Per-language config override ([python] serde_rename_all = "...")
  2. Language default (idiomatic per-language JSON wire convention):
    • camelCase: node, wasm, java, csharp, php, kotlin, swift, dart
    • snake_case: python, ruby, go, ffi, elixir, r, rust, zig, c
Source

pub fn rewrite_path(&self, rust_path: &str) -> String

Rewrite a Rust path using path_mappings.

Matches the longest prefix first so more-specific mappings take priority over broader ones.

Source

pub fn bridge_associated_types(&self) -> HashSet<String>

Collect all associated type names declared across every configured trait bridge.

Returns the union of crate::config::TraitBridgeConfig::associated_type_names for all bridges. Backends use this set to skip generic record/enum codegen for these types, deferring to visitor-specific generators instead.

Source

pub fn resolved_version(&self) -> Option<String>

Attempt to read the resolved version string from the configured version_from file.

Returns None if the file cannot be read or the version cannot be found. Checks [workspace.package] version first, then [package] version.

Source§

impl ResolvedCrateConfig

Source

pub fn try_github_repo(&self) -> Result<String, String>

Get the GitHub repository URL, returning an error when no source has it set.

Resolution order:

  1. [e2e.registry] github_repo
  2. [scaffold] repository
Source

pub fn github_repo(&self) -> String

Get the GitHub repository URL with a vendor-neutral placeholder fallback.

Source

pub fn go_module(&self) -> String

Get the Go module path with a vendor-neutral placeholder fallback.

Source

pub fn java_package(&self) -> String

Get the Java package name with a vendor-neutral placeholder fallback.

Source

pub fn java_group_id(&self) -> String

Get the Java Maven groupId.

Prefers the explicit [java] group_id override when set; otherwise falls back to the Java package name (most projects publish under groupId == java package).

Source

pub fn java_artifact_id(&self) -> String

Get the Java Maven artifactId.

Prefers the explicit [java] artifact_id override; otherwise falls back to the crate name ([[crates]] name).

Source

pub fn kotlin_package(&self) -> String

Get the Kotlin package name with a vendor-neutral placeholder fallback.

Source

pub fn csharp_namespace(&self) -> String

Get the C# namespace.

Source§

impl ResolvedCrateConfig

Source

pub fn core_import_name(&self) -> String

Get the core crate Rust import path (e.g., "liter_llm").

Returns [crate] core_import if set, otherwise derives it from the crate name by replacing hyphens with underscores.

Source

pub fn error_type_name(&self) -> String

Get the crate error type name (e.g., "KreuzbergError").

Returns [crate] error_type if set, otherwise "Error".

Source

pub fn error_constructor_expr(&self) -> String

Get the error constructor pattern. {msg} is replaced with the message expression.

Returns [crate] error_constructor if set, otherwise generates "{core_import}::{error_type}::from({msg})".

Source

pub fn core_crate_dir(&self) -> String

Get the directory name of the core crate (derived from sources or falling back to name).

For example, if sources contains "crates/html-to-markdown/src/lib.rs", this returns "html-to-markdown". Used by the scaffold to generate correct path = "../../crates/…" references in binding-crate Cargo.toml files.

Source

pub fn core_crate_for_language(&self, lang: Language) -> String

Resolve the core Cargo dependency name (and matching directory) for a language’s binding crate.

Returns [<lang>].core_crate_override when set (currently honored for wasm, dart, swift), otherwise falls back to Self::core_crate_dir.

Source

pub fn core_import_for_language(&self, lang: Language) -> String

Resolve the core crate Rust import path for a language’s binding crate.

When [<lang>].core_crate_override is set, the override name (with - translated to _) is used so that generated use paths and From impls reference the overridden crate. Otherwise falls back to Self::core_import_name.

Source

pub fn effective_path_mappings(&self) -> HashMap<String, String>

Return the effective path mappings for this crate.

When auto_path_mappings is true, automatically derives a mapping from each source crate to the configured core_import facade. For each source file whose path contains crates/{crate-name}/src/, a mapping {crate_name}{core_import} is added (hyphens in the crate name are converted to underscores). Source crates that already equal core_import are skipped.

Explicit entries in path_mappings always override auto-derived ones.

Source§

impl ResolvedCrateConfig

Source

pub fn package_dir(&self, lang: Language) -> String

Get the package output directory for a language. Uses scaffold_output from per-language config if set, otherwise defaults.

Source

pub fn run_wrapper_for_language(&self, lang: Language) -> Option<&str>

Get the run_wrapper for a language, if set.

Source

pub fn extra_lint_paths_for_language(&self, lang: Language) -> &[String]

Get the extra_lint_paths for a language.

Source

pub fn project_file_for_language(&self, lang: Language) -> Option<&str>

Get the project_file for a language (Java or C# only).

Source

pub fn lint_config_for_language(&self, lang: Language) -> LintConfig

Get the effective lint configuration for a language.

Source

pub fn update_config_for_language(&self, lang: Language) -> UpdateConfig

Get the effective update configuration for a language.

Source

pub fn test_config_for_language(&self, lang: Language) -> TestConfig

Get the effective test configuration for a language.

Source

pub fn setup_config_for_language(&self, lang: Language) -> SetupConfig

Get the effective setup configuration for a language.

Source

pub fn clean_config_for_language(&self, lang: Language) -> CleanConfig

Get the effective clean configuration for a language.

Source

pub fn build_command_config_for_language( &self, lang: Language, ) -> BuildCommandConfig

Get the effective build command configuration for a language.

Source

pub fn features_for_language(&self, lang: Language) -> &[String]

Get the features to use for a specific language’s binding crate.

Source

pub fn extra_deps_for_language(&self, lang: Language) -> HashMap<String, Value>

Get the merged extra dependencies for a specific language’s binding crate.

Source§

impl ResolvedCrateConfig

Source

pub fn python_module_name(&self) -> String

Get the Python module name.

Source

pub fn node_package_name(&self) -> String

Get the Node package name.

Source

pub fn ruby_gem_name(&self) -> String

Get the Ruby gem name.

Source

pub fn php_extension_name(&self) -> String

Get the PHP extension name.

Source

pub fn php_cargo_crate_name(&self) -> Option<&str>

Get the PHP binding Cargo crate name (used for deriving the shared library filename).

Source

pub fn elixir_app_name(&self) -> String

Get the Elixir app name.

Source

pub fn zig_module_name(&self) -> String

Get the Zig module name.

Source

pub fn dart_pubspec_name(&self) -> String

Get the Dart pubspec package name.

Returns [dart] pubspec_name if set, otherwise derives a snake_case name from the crate name by replacing hyphens with underscores.

Source

pub fn dart_bridge_class_name(&self) -> String

Get the Dart FRB bridge class name.

Converts [dart] lib_name (falling back to dart_pubspec_name()) to PascalCase and appends "Bridge", matching the FRB v2 convention. E.g. lib_name = "kreuzcrawl""KreuzcrawlBridge".

Source

pub fn swift_module(&self) -> String

Get the Swift module name.

Returns [swift] module_name if configured, otherwise derives a PascalCase name from the crate name (e.g. "my-lib""MyLib").

Source

pub fn r_package_name(&self) -> String

Get the R package name.

Source

pub fn wasm_type_prefix(&self) -> String

Get the WASM type name prefix (e.g. “Wasm” produces WasmConversionOptions). Defaults to "Wasm".

Source

pub fn node_type_prefix(&self) -> String

Get the Node/NAPI type name prefix (e.g. “Js” produces JsConversionOptions). Defaults to "Js".

Source§

impl ResolvedCrateConfig

Source

pub fn output_for(&self, lang: &str) -> Option<&Path>

Convenience accessor: the resolved output directory for a language. Returns None if this crate does not target the language.

Source

pub fn targets(&self, lang: Language) -> bool

Whether this crate targets the given language.

Trait Implementations§

Source§

impl Clone for ResolvedCrateConfig

Source§

fn clone(&self) -> ResolvedCrateConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResolvedCrateConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ResolvedCrateConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ResolvedCrateConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,