| Crates.io | fluxhead |
| lib.rs | fluxhead |
| version | 0.1.0 |
| created_at | 2025-08-21 13:13:48.722005+00 |
| updated_at | 2025-08-21 13:13:48.722005+00 |
| description | A library to decode g64 images |
| homepage | |
| repository | https://github.com/markusstoller/fluxhead |
| max_upload_size | |
| id | 1804833 |
| size | 4,462,355 |
A Rust library and toolkit for parsing and inspecting Commodore 1541/CBM DOS GCR data from G64 disk images. It provides helpers to read G64 headers, track locations, and decode GCR-encoded track headers and data into their binary representation.
Fluxhead focuses on reading and parsing G64 disk images:
This is useful for experimental disk analysis, visualization, or building higher-level tooling for Commodore 1541 disk formats.
Add to your Cargo.toml if using as a dependency:
[dependencies]
fluxhead = { path = "." }
Or, if published on crates.io in the future:
[dependencies]
fluxhead = "0.x"
From the repository root:
cargo build
cargo test
The library provides a simple Fluxhead type to parse in-memory buffers and print debug details:
use fluxhead::Fluxhead;
fn main() {
// Load a G64 file into memory and parse it
let data = std::fs::read("path/to/disk.g64").expect("read g64");
let mut flux = Fluxhead::new();
flux.parse_from_buffer(&data);
}
If you have a path on disk and want to use the convenience method in tests (as demonstrated in the repo tests):
use fluxhead::Fluxhead;
fn parse_file(path: &str) {
let mut flux = Fluxhead::new();
// Parses the file and returns an optional ParsedData
let _parsed = flux.parse_from_file(path);
}
Internally, the parser scans for sync patterns (0xFF bytes) and known identifiers:
When found, it decodes the GCR-encoded segments using cbm_dos::GCR and populates simple structures:
pub struct SectorHeader {
pub gcr_encoded_data: Vec<u8>,
pub gcr_decoded_data: Vec<u8>,
}
pub struct SectorData {
pub gcr_encoded_data: Vec<u8>,
pub gcr_decoded_data: Vec<u8>,
}
pub struct Sector {
pub header: SectorHeader,
pub data: SectorData,
}
pub struct Track {
pub tracks: Option<Vec<Sector>>,
pub speed_zone: i32,
}
You can adapt the parsing to collect all tracks and use them downstream (e.g., integrity checks, metadata extraction).
Key types (see src/lib.rs):
Public items exposed for consumers:
The implementation uses the endian_codec and cbm_dos crates for binary and GCR decoding.
cargo fmtcargo clippycargo testTips:
Contributions are welcome! Please open an issue or pull request. When contributing code:
Specify your preferred license here (e.g., MIT/Apache-2.0). Add the corresponding LICENSE files to the repository.