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:
-
Add a logger to your Cargo.toml:
[dependencies] env_logger = "0.11" -
Initialize the logger in your code:
fn main() { env_logger::init(); // ... your code using quarry } -
Run with debug environment variables:
RUST_LOG=debug- Show all debug messagesRUST_LOG=quarry=debug- Show only Quarry debug messagesRUST_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§
- Field
Info - Information about a struct field
- Struct
Info - Complete information about a struct
Enums§
- Quarry
Error - 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