workspacer-crate
workspacer-crate is a core library in the Workspacer suite that focuses on analyzing individual Rust crates. It provides functionality to:
-
Extract Public Interfaces:
Wrap public items (functions, structs, enums, traits, type aliases, and macros) into a unified interface using theCrateInterfaceItemtype. -
Analyze Crate Metrics:
Compute useful metrics such as total file size, lines of code, number of source files, and test files through asynchronous analysis (CrateAnalysis). -
Unified Crate Handling:
Offer a high-levelCrateHandleto manage crate-related operations, including integrity checks (e.g. verifying the existence of essential files likeCargo.toml,lib.rs/main.rs, andREADME.md), fetching source files with exclusions, and more. -
Mock Crate Configuration:
Easily configure and create mock crates for testing purposes usingCrateConfig.
This crate leverages Tokio for asynchronous file I/O, along with a suite of helper libraries from the Workspacer ecosystem to provide an efficient, non-blocking approach to analyzing Rust projects.
Features
-
Async File Analysis:
Uses Tokio's async APIs to read files, count lines, and calculate file sizes without blocking your runtime. -
Interface Extraction:
Automatically extracts and displays public API items (e.g., functions, structs, traits) for further processing or documentation. -
Comprehensive Integrity Checks:
Ensures that critical files exist (e.g.,Cargo.toml,lib.rs/main.rs, andREADME.md) to verify crate validity. -
Extensible & Modular:
Designed to integrate seamlessly with other parts of the Workspacer suite (such as workspacer-consolidate and workspacer-interface).
Installation
Add the following to your Cargo.toml:
[]
= "0.1.0"
Usage
Below is an example of how to use workspacer-crate to analyze a Rust crate:
use ;
use PathBuf;
use tokio;
async
Contributing
Contributions to workspacer-crate are welcome! Please refer to the repository for guidelines on contributing and reporting issues.
License
This project is dual-licensed under either the MIT license or the Apache License, Version 2.0, at your option.