Crate quarry

Source
Expand description

§Quarry

Quarry is a Rust library for mining type information from the Rust standard library. It provides access to struct field information, including private fields, by analyzing the actual standard library installed on your system.

§Scope and Limitations

Current Focus: Quarry currently analyzes structs only. Popular types like Option<T> and Result<T, E> (which are enums) cannot be analyzed yet.

Planned Features: Support for enums, traits, and other types is planned for future releases. If you need enum analysis immediately, consider using rustdoc directly.

§Requirements

  • Nightly Rust Toolchain: Required for rustdoc JSON generation
  • rust-src Component: Install with rustup component add rust-src --toolchain nightly

§Usage Philosophy

Quarry requires explicit, full module paths to ensure unambiguous type resolution. Instead of accepting short names like “String”, you must specify “alloc::string::String”. This design choice eliminates ambiguity and makes your code more explicit about which specific type you’re analyzing.

§Example

use quarry::mine_struct_info;

// Analyze the String type from the alloc crate
let result = mine_struct_info("alloc::string::String")?;
println!("Struct: {}", result.name);
println!("Simple name: {}", result.simple_name);
println!("Module path: {}", result.module_path);

// Access field information (including private fields)
for field in result.fields {
    println!("  Field: {} -> {} (public: {})",
             field.name, field.type_name, field.is_public);
}

// List all available types
let all_types = quarry::list_stdlib_structs()?;
println!("Found {} standard library struct types", all_types.len());

§Debug Logging

Quarry provides detailed debug logging to help understand the standard library analysis process. To enable debug output:

  1. Add a logger to your Cargo.toml:

    [dependencies]
    env_logger = "0.11"
  2. Initialize the logger in your code:

    fn main() {
        env_logger::init();
        // ... your code using quarry
    }
  3. Run with debug environment variables:

    • RUST_LOG=debug - Show all debug messages
    • RUST_LOG=quarry=debug - Show only Quarry debug messages
    • RUST_LOG=quarry::stdlib=debug - Show only stdlib module debug messages

Example: RUST_LOG=quarry=debug cargo run

Modules§

stdlib
Dynamic analysis of Rust standard library types

Structs§

FieldInfo
Information about a struct field
StructInfo
Complete information about a struct

Enums§

QuarryError
Errors that can occur when mining standard library type information

Functions§

cache_stats
Get statistics about the standard library cache
clear_stdlib_cache
Clear the standard library cache
init_stdlib_cache
Initialize the standard library cache
is_stdlib_struct
Check if a type name refers to a standard library struct
list_stdlib_structs
List all available standard library struct types
mine_struct_info
Mine struct information from the Rust standard library

Type Aliases§

Result