How jameshiew/rsc-extractor works
Project Type and Purpose
• This is a Rust-based command-line tool (“rsc-extractor”) for parsing and extracting assets (e.g. .dmi, .midi) from BYOND .rsc resource bundles.
• In addition to the end-user CLI (crates/rsc-extractor), it includes an “xtask” subproject (xtask/) that provides developer automation commands (download sample archives, unzip, batch-analyze, batch-extract).
File Structure Analysis
• Top level
• Cargo.toml, Justfile, CI configs, LICENSE, README.md
• crates/rsc-extractor
• Binary + library modules:
– main.rs (entry point & CLI parsing)
– extractor.rs (core parsing logic)
– validation.rs (pre-check on .rsc format)
– types.rs (shared data models)
– output.rs (file system sink)
– display.rs (console reporting)
– error.rs (error types & handling)
• xtask
• Standalone Rust binary with subcommands under src/commands:
– download.rs (fetch archive from Internet Archive)
– unzip/bpp extraction
– analyze.rs & extract.rs (invoke rsc-extractor logic programmatically)
– utils.rs (common routines)
README Insights
• Confirms two CLIs:
a) rsc-extractor for one-off extraction/analysis
b) cargo xtask ... for batch or dev workflows
• References external service (Internet Archive) for sample data downloads.
• Describes user flow: install → run → optionally run xtask to manage large data sets.
a. Main Components
• User CLI (rsc-extractor)
• Core Library Modules (Validation → Extraction → Output → Display)
• Filesystem (Input .rsc file, Output asset directory)
• Developer CLI (xtask)
• External Service (Internet Archive HTTP API)
• Zip/Unzip Engine (for archive handling in xtask)
b. Relationships & Data Flow
1. User invokes rsc-extractor some.rsc
2. CLI parses flags, calls Validation module
3. On success, Extraction module reads and decodes binary streams into in-memory asset objects (via Types)
4. Output module writes assets to disk; Display module prints summary to console
5. xtask: user invokes cargo xtask download-bpp → HTTP client fetches ZIP → unzip command unpacks → xtask analyze-all loops through .rsc files and invokes the same Library API used by rsc-extractor → stores results
c. Architectural Patterns & Principles
• Layered Modular Design:
• CLI layer
• Core logic layer
• IO/Output layer
• Single Responsibility per module
• Reusability: xtask reuses the core library rather than shelling out to the binary
d. Key Technologies & Frameworks
• Rust toolchain & Cargo workspace
• Clap or StructOpt (implied for CLI parsing)
• HTTP client (reqwest or similar) in xtask
• std::fs and zip/unzip crates for archive handling
• workspace / xtask pattern (per matklad’s cargo-xtask)