Skip to main content

ResolvedCrateConfig

Struct ResolvedCrateConfig 

Source
pub struct ResolvedCrateConfig {
Show 57 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 gleam: Option<GleamConfig>, pub go: Option<GoConfig>, pub java: Option<JavaConfig>, pub dart: Option<DartConfig>, pub kotlin: Option<KotlinConfig>, pub swift: Option<SwiftConfig>, 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>§gleam: Option<GleamConfig>§go: Option<GoConfig>§java: Option<JavaConfig>§dart: Option<DartConfig>§kotlin: Option<KotlinConfig>§swift: Option<SwiftConfig>§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 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§

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:
    • camelCase: node, wasm, java, csharp
    • snake_case: all others
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 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.

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 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>,