| Crates.io | puz-parse |
| lib.rs | puz-parse |
| version | 0.1.2 |
| created_at | 2025-07-25 17:49:59.745089+00 |
| updated_at | 2025-10-20 15:55:06.977114+00 |
| description | A Rust library for parsing .puz crossword puzzle files |
| homepage | https://github.com/mwln/puz.rs |
| repository | https://github.com/mwln/puz.rs |
| max_upload_size | |
| id | 1767878 |
| size | 106,237 |
A Rust library for parsing .puz crossword puzzle files.
This library provides functionality to parse the binary .puz file format used by crossword puzzle applications like AcrossLite. It extracts puzzle metadata, grids, clues, and advanced features like rebus squares and circled squares.
Add this to your Cargo.toml:
[dependencies]
puz-parse = "0.1.0"
# For JSON serialization support:
puz-parse = { version = "0.1.0", features = ["json"] }
use puz_parse::parse_file;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Parse a .puz file
let puzzle = parse_file("puzzle.puz")?;
// Access puzzle information
println!("Title: {}", puzzle.info.title);
println!("Author: {}", puzzle.info.author);
println!("Size: {}x{}", puzzle.info.width, puzzle.info.height);
// Access clues
for (num, clue) in &puzzle.clues.across {
println!("{} Across: {}", num, clue);
}
Ok(())
}
For more control over parsing and error handling:
use std::fs::File;
use puz_parse::parse;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let file = File::open("puzzle.puz")?;
let result = parse(file)?;
let puzzle = result.result;
// Handle any warnings that occurred during parsing
for warning in &result.warnings {
eprintln!("Warning: {}", warning);
}
Ok(())
}
The parsed puzzle contains:
info - Metadata (title, author, dimensions, etc.)grid - Solution and blank gridsclues - Across and down clues by numberextensions - Advanced features (rebus, circles, given squares)See the examples directory for more detailed usage examples.
This library supports the complete .puz file format specification, including:
The library provides detailed error information:
use puz_parse::parse_file;
match parse_file("puzzle.puz") {
Ok(puzzle) => {
println!("Successfully parsed: {}", puzzle.info.title);
}
Err(e) => {
eprintln!("Parse error: {}", e);
}
}
This project is licensed under the MIT License - see the LICENSE file for details.