Skip to content
Snippets Groups Projects
Commit db87c0bc authored by Tasuku SUENAGA a.k.a. gunyarakun's avatar Tasuku SUENAGA a.k.a. gunyarakun Committed by Nguyen Anh Quynh
Browse files

bindings: make the sample code in README.md for Rust compilable (#322)

parent 5bcff118
Branches
Tags
No related merge requests found
......@@ -4,19 +4,23 @@ Rust bindings for the [keystone](http://www.keystone-engine.org/) engine.
## Sample
```rust
extern crate keystone;
use keystone::{Keystone, Arch, Mode, OptionType, OptionValue};
use keystone::*;
fn main() {
let engine = Keystone::new(Arch::X86, Mode::Mode32)
let engine = Keystone::new(Arch::X86, MODE_32)
.expect("Could not initialize Keystone engine");
engine.option(OptionType::Syntax, OptionValue::SyntaxNASM)
engine.option(OptionType::SYNTAX, OPT_SYNTAX_NASM)
.expect("Could not set option to nasm syntax");
let result = engine.asm("mov ah, 0x80".to_string(), 0)
.expect("Could not assemble");
let _ = result;
println!("ASM result: {}", result);
if let Err(err) = engine.asm("INVALID".to_string(), 0) {
println!("Error: {}", err);
}
}
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment