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)] 12 #[path = "../../monster_test_generated.rs"] 13 mod monster_test_generated; 14 pub use monster_test_generated::my_game; 15 16 17 use std::io::Read; 18 main()19fn main() { 20 let mut f = std::fs::File::open("../monsterdata_test.mon").unwrap(); 21 let mut buf = Vec::new(); 22 f.read_to_end(&mut buf).expect("file reading failed"); 23 24 let monster = my_game::example::get_root_as_monster(&buf[..]); 25 println!("{}", monster.hp()); // `80` 26 println!("{}", monster.mana()); // default value of `150` 27 println!("{:?}", monster.name()); // Some("MyMonster") 28 } 29