diff options
| author | Matthieu Pignolet <matthieu@puffer.fish> | 2025-05-24 10:26:31 +0400 |
|---|---|---|
| committer | Matthieu Pignolet <matthieu@puffer.fish> | 2025-05-24 10:26:31 +0400 |
| commit | 971e39e9955a7c65488514bb30ba3727dd0b7539 (patch) | |
| tree | 80523fba6cd8b0599d073ec767733b7154a014db | |
| parent | 4db7f2f0922159ba8c5a5a28ae480a396e915541 (diff) | |
feat: make indexing work with stdin & stdout
| -rw-r--r-- | bin/index/src/main.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/bin/index/src/main.rs b/bin/index/src/main.rs index 31eb49f..79780c9 100644 --- a/bin/index/src/main.rs +++ b/bin/index/src/main.rs @@ -1,4 +1,4 @@ -use std::fs; +use std::io::{stdin, stdout}; use db::{ save::Save, @@ -15,8 +15,7 @@ fn main() { .escape(Some(b'\\')) .flexible(true) .comment(Some(b'#')) - .from_path("./data/all.csv") - .unwrap(); + .from_reader(stdin()); let mut phonems = vec![]; @@ -41,11 +40,11 @@ fn main() { save.trie.insert(&phoneme); } - fs::write( - "data/db.bin", - bincode::encode_to_vec(bincode::serde::Compat(&save), bincode::config::standard()).unwrap(), + let mut stdout = stdout(); + bincode::encode_into_std_write( + bincode::serde::Compat(&save), + &mut stdout, + bincode::config::standard(), ) .unwrap(); - - println!("Generated to assets/db.bin"); } |
