| Crates.io | intelhex-rs |
| lib.rs | intelhex-rs |
| version | 0.1.1 |
| created_at | 2025-09-27 14:57:08.057416+00 |
| updated_at | 2025-09-27 14:57:08.057416+00 |
| description | A robust Intel HEX format parser and writer |
| homepage | |
| repository | https://github.com/tohrxyk/intelhex-rs |
| max_upload_size | |
| id | 1857382 |
| size | 48,765 |
A robust Rust library for parsing and writing Intel HEX format files. This library provides a safe and efficient way to handle Intel HEX format data, commonly used in embedded systems programming.
Add this to your Cargo.toml:
[dependencies]
intelhex-rs = "0.1.1"
use intelhex::IntelHex;
// Parse Intel HEX format text
let hex_text = ":10010000214601360121470136007EFE09D2190140\n:00000001FF";
let intel_hex = IntelHex::from_intel_hex_text(hex_text).unwrap();
// Access memory contents
let memory = intel_hex.memory_cells();
if let Some(&value) = memory.get(&0x0100) {
println!("Value at 0x100: {:02X}", value);
}
// Write back to Intel HEX format
let output = intel_hex.to_intel_hex_text().unwrap();
use intelhex::{IntelHex, MemoryDataBlock};
let mut intel_hex = IntelHex::new();
// Add a memory block
let block = MemoryDataBlock {
address: 0x1000,
data: vec![0x12, 0x34, 0x56],
};
intel_hex.add_memory_block(&block).unwrap();
// Get continuous memory blocks
let blocks = intel_hex.memory_blocks();
for block in blocks {
println!("Block at {:08X}, length: {}", block.address, block.data.len());
}
use std::fs::File;
use intelhex::IntelHex;
// Read from file
let file = File::open("firmware.hex").unwrap();
let intel_hex = IntelHex::from_reader(file).unwrap();
// Write to file
let output = File::create("output.hex").unwrap();
intel_hex.to_writer(output, 16).unwrap(); // 16 bytes per data record
For detailed API documentation, run:
cargo doc --open
Run the test suite with:
cargo test
This project is licensed under the MIT License. See the LICENSE file for details.
We welcome contributions to improve the library. Please feel free to submit a Pull Request.