| Crates.io | mame-parser |
| lib.rs | mame-parser |
| version | 0.7.2 |
| created_at | 2024-09-05 22:45:00.23975+00 |
| updated_at | 2024-09-28 01:02:36.322227+00 |
| description | Library to read and write MAME files |
| homepage | |
| repository | https://github.com/retro-arcade-games/mame-parser |
| max_upload_size | |
| id | 1365242 |
| size | 372,170 |
Simplify the management and processing of files containing MAME data
Features • Library Contents • Getting Started • Credits • Contribute • License
mame-parser is a Rust library designed to simplify the management and processing of files containing MAME (Multiple Arcade Machine Emulator) data. This library provides a comprehensive suite of tools to automate the downloading, decompression, parsing, and exporting of MAME data, making it easier to handle and manipulate this information in various formats.
download_file: Downloads a single MAME data file to a specified location.download_files: Downloads multiple MAME data files concurrently, providing progress tracking across multiple threads.unpack_file: Unpacks a single downloaded file from its archive format (e.g., ZIP or 7z) to a specified folder.unpack_files: Unpacks multiple files concurrently, allowing for efficient decompression with progress tracking.read_file: Reads a single data file and returns a HashMap with the information.read_files: Reads multiple data files concurrently and returns a HashMap with the information.remove_machines_by_category: Filters machines based on a specific category, removing all machines that do not match the given category.remove_machines_by_filter: Applies multiple filters to the machines, such as removing non-game machines, BIOS machines, mechanical machines, device machines, clones, or modified machines.write_files: Writes machine data to the desired format (SQLite, JSON, or CSV), establishing all necessary relationships and providing progress updates.Tools and types for tracking and managing progress updates during operations.
Functions for reading and parsing different MAME data file formats.
To get started with mame-parser, follow these steps:
Add mame-parser as a dependency in your Cargo.toml file:
[dependencies]
mame-parser = "0.7.0"
Make sure to replace "0.7.0" with the actual version of mame-parser that you intend to use.
use mame_parser::file_handling::download_file;
use mame_parser::models::MameDataType;
use mame_parser::progress::{CallbackType, ProgressCallback, ProgressInfo};
use std::error::Error;
use std::path::Path;
fn main() -> Result<(), Box<dyn Error>> {
// Define the workspace directory
let workspace_path = Path::new("playground");
// Define a callback function for progress tracking
let progress_callback: ProgressCallback = Box::new(move |progress_info: ProgressInfo| {
// Update progress using console messages
match progress_info.callback_type {
CallbackType::Progress => {
println!(
"Progress: {}/{}",
progress_info.progress, progress_info.total
);
}
CallbackType::Info => {
println!("Info: {}", progress_info.message);
}
CallbackType::Finish => {
println!("Finished: {}", progress_info.message);
}
CallbackType::Error => {
eprintln!("Error: {}", progress_info.message);
}
}
});
// Download the file
let downloaded_file = download_file(MameDataType::Series, workspace_path, progress_callback);
// Print the result
match downloaded_file {
Ok(downloaded_file) => {
println!(
"Downloaded file: {}",
downloaded_file.as_path().to_str().unwrap()
);
}
Err(e) => {
eprintln!("Error during download: {}", e);
}
}
Ok(())
}
To run the example, create a Rust project, add the code above to your main.rs file, and run:
cargo run
Make sure you have an active internet connection, as the example involves downloading files from the web.
mame-parser wouldn't be possible without the invaluable contributions and resources provided by the following individuals and communities:
The MAME Community: A special thanks to the entire MAME community for their continuous efforts in preserving arcade history and making it accessible to everyone. Your work is the foundation upon which this project is built.
AntoPISA and Progetto-SNAPS: AntoPISA's Progetto-SNAPS project has been an essential resource for MAME artwork and other assets. Thank you for your dedication and hard work in creating and maintaining this incredible resource.
Motoschifo and Arcade Database (ADB): Motoschifo's Arcade Database is a comprehensive resource for MAME data, providing detailed information about arcade games and machines.
Arcade-History: The team behind Arcade-History has done an amazing job in documenting the history of arcade games.
NPlayers Team: The NPlayers project by Arcade Belgium is a fantastic resource for information on multiplayer arcade games.
zombiesbyte and XMLTractor: Special thanks to zombiesbyte for XMLTractor project.
Contributions are welcome! If you'd like to contribute, please fork the repository, create a new branch, and submit a pull request. Make sure to follow the project's coding guidelines and include tests where applicable.
This project is licensed under the MIT License - see the LICENSE file for details.