Skip to main content

Crate ryo_metadata

Crate ryo_metadata 

Source
Expand description

ryo-metadata: Cargo workspace and crate metadata resolution

This crate provides accurate crate name resolution for Rust projects, solving the “crate::” vs actual crate name problem.

§Problem

When analyzing Rust source code, internal references like crate::config need to be resolved to their actual crate names like ryo_app::config.

§Solution

Use cargo metadata to:

  1. Discover workspace members
  2. Map file paths to crate names
  3. Provide accurate SymbolPath resolution

§Example

use ryo_metadata::WorkspaceResolver;

let resolver = WorkspaceResolver::from_manifest("Cargo.toml")?;

// Get crate name for a file
let crate_name = resolver.crate_for_file("crates/ryo-app/src/lib.rs");
assert_eq!(crate_name, Some("ryo_app"));

// Get all workspace members
for member in resolver.members() {
    println!("{}: {}", member.name, member.manifest_path);
}

Re-exports§

pub use cargo_metadata;

Structs§

CrateInfo
Information about a crate in the workspace
Metadata
Starting point for metadata returned by cargo metadata
MetadataCommand
A builder for configuring cargo metadata invocation.
Package
One or more crates described by a single Cargo.toml
ResolvedCrateName
A crate name that has been resolved from Cargo.toml
ResolvedFile
A fully resolved file with guaranteed correct crate/module information
ResolvedModulePath
A module path that has been resolved from file location
WorkspaceResolver
Resolves file paths to crate names using cargo metadata

Enums§

MetadataError
Errors that can occur during metadata resolution

Type Aliases§

Result
Result type for ryo-metadata operations