-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
35 lines (27 loc) · 831 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::path::Path;
use std::fs::File;
use std::io::{BufReader, BufWriter};
use std::env;
extern crate thiserror;
extern crate regex;
extern crate quick_xml as xml;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate bincode;
use bincode::Options;
#[path = "src/metadata/loader.rs"]
mod loader;
#[path = "src/error.rs"]
mod error;
fn main() {
let metadata = loader::load(BufReader::new(
File::open("assets/PhoneNumberMetadata.xml")
.expect("could not open metadata file")))
.expect("failed to load metadata");
let mut out = BufWriter::new(File::create(
&Path::new(&env::var("OUT_DIR").unwrap()).join("database.bin"))
.expect("could not create database file"));
bincode::options().with_varint_encoding().serialize_into(&mut out, &metadata)
.expect("failed to serialize database");
}