mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 20:15:34 +00:00
* Updated comments and fixed a fundemental type error. * bump rust flatbuffers semver * Initial commit with verifier, need to clean up * Verifier tested. Needs clean up and refactoring. * Display for InvalidFlatbuffer and better errors for strings * SimpleToVerify, some refactoring * Combined VerifierType TableAccessorFuncBody into FollowType * scrub todos * Update Rust get_root functions. There are 6 variants, with verifier options, default verifier options and no verification "fast". * Rename root fns * inline * Update to use thiserror * fix for bad compiler * improve error formatting * Replace multiply with saturating_multiply * saturating adds too * Add docs disclaiming experimental verification system Co-authored-by: Casper Neo <cneo@google.com>
28 lines
869 B
Rust
28 lines
869 B
Rust
extern crate flatbuffers;
|
|
|
|
#[allow(dead_code, unused_imports)]
|
|
#[path = "../../include_test/include_test1_generated.rs"]
|
|
pub mod include_test1_generated;
|
|
|
|
#[allow(dead_code, unused_imports)]
|
|
#[path = "../../include_test/sub/include_test2_generated.rs"]
|
|
pub mod include_test2_generated;
|
|
|
|
#[allow(dead_code, unused_imports)]
|
|
#[path = "../../monster_test_generated.rs"]
|
|
mod monster_test_generated;
|
|
pub use monster_test_generated::my_game;
|
|
|
|
use std::io::Read;
|
|
|
|
fn main() {
|
|
let mut f = std::fs::File::open("../monsterdata_test.mon").unwrap();
|
|
let mut buf = Vec::new();
|
|
f.read_to_end(&mut buf).expect("file reading failed");
|
|
|
|
let monster = my_game::example::root_as_monster(&buf[..]).unwrap();
|
|
println!("{}", monster.hp()); // `80`
|
|
println!("{}", monster.mana()); // default value of `150`
|
|
println!("{:?}", monster.name()); // Some("MyMonster")
|
|
}
|