• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 extern crate flatbuffers;
2 
3 #[path = "../../monster_test_generated.rs"]
4 mod monster_test_generated;
5 pub use monster_test_generated::my_game;
6 
7 use std::io::Read;
8 
main()9 fn main() {
10     let mut f = std::fs::File::open("../monsterdata_test.mon").unwrap();
11     let mut buf = Vec::new();
12     f.read_to_end(&mut buf).expect("file reading failed");
13 
14     let monster = my_game::example::get_root_as_monster(&buf[..]);
15     println!("{}", monster.hp());     // `80`
16     println!("{}", monster.mana());   // default value of `150`
17     println!("{:?}", monster.name()); // Some("MyMonster")
18 }
19