Skip to content

Commit

Permalink
variable int encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
SevInf committed Dec 22, 2023
1 parent e11c803 commit 251b1b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions psl/compile-schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ version = "0.1.0"
[dependencies]
psl = { path = "../psl" }
bincode = "1.3.1"
serde.workspace = true
9 changes: 7 additions & 2 deletions psl/compile-schema/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::env;
use std::fs;

use bincode::DefaultOptions;
use bincode::Options;
use psl::Diagnostics;
use serde::Serialize;

fn main() {
let args: Vec<String> = env::args().collect();
Expand All @@ -11,7 +14,9 @@ fn main() {
let in_contents = fs::read_to_string(in_file).expect("Can not read in file");
let mut diagnostics = Diagnostics::new();
let ast = psl::schema_ast::parse_schema(&in_contents, &mut diagnostics);
let encoded = bincode::serialize(&ast).unwrap();

fs::write(out_file, encoded).unwrap();
let bincode_options = bincode::options().with_varint_encoding();
bincode_options
.serialize_into(fs::File::create(out_file).unwrap(), &ast)
.unwrap()
}

0 comments on commit 251b1b2

Please sign in to comment.