1 extern crate flatbuffers; 2 3 #[allow(dead_code, unused_imports)] 4 #[path = "../../include_test/include_test1_generated.rs"] 5 pub mod include_test1_generated; 6 7 #[allow(dead_code, unused_imports)] 8 #[path = "../../include_test/sub/include_test2_generated.rs"] 9 pub mod include_test2_generated; 10 11 #[allow(dead_code, unused_imports, clippy::approx_constant)] 12 #[path = "../../monster_test_generated.rs"] 13 mod monster_test_generated; 14 pub use monster_test_generated::my_game; 15 16 use std::io::Read; 17 main()18fn main() { 19 let mut f = std::fs::File::open("../monsterdata_test.mon").unwrap(); 20 let mut buf = Vec::new(); 21 f.read_to_end(&mut buf).expect("file reading failed"); 22 23 let monster = my_game::example::root_as_monster(&buf[..]).unwrap(); 24 println!("{}", monster.hp()); // `80` 25 println!("{}", monster.mana()); // default value of `150` 26 println!("{:?}", monster.name()); // Some("MyMonster") 27 } 28