Skip to content

lang.rust #

fn detect_source_package #

fn detect_source_package(source_path string) !SourcePackageInfo

Detect source package and module information from a path

fn determine_crate_path #

fn determine_crate_path(source_code_path string) !string

Determines the crate path from the source code path

fn extract_dependencies #

fn extract_dependencies(cargo_path string) !map[string]string

Extract dependencies from Cargo.toml

fn extract_functions_from_content #

fn extract_functions_from_content(content string) []string

Extract function names from content string

fn extract_imports #

fn extract_imports(file_path string) ![]string

Extract imports from a Rust file

fn extract_imports_from_content #

fn extract_imports_from_content(content string) []string

Extract imports from content string

fn extract_module_name_from_path #

fn extract_module_name_from_path(path string) string

Extracts the module name from a directory path

fn extract_structs_from_content #

fn extract_structs_from_content(content string) []string

Extract struct names from content string

fn generate_import_statement #

fn generate_import_statement(current_file_path string, target_module_path string) !string

Generate an import statement for a module based on current file and target module path

fn get_function_from_content #

fn get_function_from_content(content string, function_name string) !string

Get a function declaration from content by its name

fn get_function_from_file #

fn get_function_from_file(file_path string, function_name string) !string

Get a function declaration from a file by its name

fn get_function_from_module #

fn get_function_from_module(module_path string, function_name string) !string

Get a function declaration from a module by its name

fn get_module_dependency #

fn get_module_dependency(importer_path string, module_path string) !ModuleDependency

Get module dependency information

fn get_module_name #

fn get_module_name(file_path string) string

Get module name from file path

fn get_struct_from_content #

fn get_struct_from_content(content string, struct_name string) !string

Get a struct declaration from content by its name

fn get_struct_from_file #

fn get_struct_from_file(file_path string, struct_name string) !string

Get a struct declaration from a file by its name

fn get_struct_from_module #

fn get_struct_from_module(module_path string, struct_name string) !string

Get a struct declaration from a module by its name

fn list_functions_in_file #

fn list_functions_in_file(file_path string) ![]string

Extract function names from Rust file

fn list_modules_in_directory #

fn list_modules_in_directory(dir_path string) ![]string

List all modules in a directory

fn list_structs_in_file #

fn list_structs_in_file(file_path string) ![]string

Extract struct names from Rust file

fn parse_rust_struct #

fn parse_rust_struct(definition string) !StructInfo

Helper function to parse a Rust struct definition from a string

fn read_source_code #

fn read_source_code(source_code_path string) !string

Reads and combines all Rust files in the given directory

fn run_example #

fn run_example(project_dir string, example_name string) !(string, string)

Build and run a Rust project with an example

struct ModuleDependency #

struct ModuleDependency {
pub mut:
	import_statement      string // The Rust import statement to use
	module_path           string // Path to the module
	package_name          string // Name of the package (crate)
	cargo_dependency      string // Line to add to Cargo.toml
	current_version       string // Current version if already a dependency
	is_already_dependency bool   // Whether the package is already a dependency
	is_in_same_project    bool   // Whether the module is in the same project
}

Information about a module dependency

struct SourcePackageInfo #

struct SourcePackageInfo {
pub:
	name   string // Package name
	path   string // Relative path to the package (for cargo.toml)
	module string // Full module path (e.g., herodb::logic)
}

Determines the source package information from a given source path

struct StructInfo #

struct StructInfo {
pub:
	struct_name string
	fields      map[string]string // field_name: field_type
}

Struct to hold parsed struct information