Crates.io | EOF-Parser |
lib.rs | EOF-Parser |
version | 0.1.0 |
source | src |
created_at | 2024-07-11 14:49:32.932971 |
updated_at | 2024-07-11 14:49:32.932971 |
description | EOF Parser is a Rust library for parsing Ethereum Object Format (EOF) files |
homepage | |
repository | |
max_upload_size | |
id | 1299646 |
size | 11,860 |
EOF Parser is a Rust library for parsing Ethereum Object Format (EOF) files. EOF is a new binary format for smart contracts on the Ethereum blockchain, designed to improve efficiency and introduce new features.
Add this to your Cargo.toml
:
[dependencies]
eof-parser = "0.1.0"
Basic usage example:
use eof_parser::Parser;
use std::fs::File;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let file = File::open("path/to/your/eof/file")?;
let mut parser = Parser::new(file);
match parser.parse() {
Ok(container) => {
println!("EOF Container parsed successfully:");
println!("Header: {:?}", container.header);
println!("Code section size: {}", container.body.code_section.len());
// Access other parsed data as needed
},
Err(e) => println!("Error parsing EOF: {:?}", e),
}
Ok(())
}
The library consists of the following main components:
Parser
: The main struct for parsing EOF filesEOFContainer
: Represents a parsed EOF containerEOFHeader
: Contains the parsed header informationBody
: Represents the parsed body of the EOF containerTypesSection
and TypeMetadata
: Represent the types section of the EOFThe library uses a custom Error
enum to handle various parsing errors, such as invalid magic numbers, unsupported versions, or malformed sections.
The library includes unit tests to ensure correct parsing of valid EOF files and proper error handling for invalid inputs. Run the tests using:
Copy
cargo test
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.