From fbed2862fda127b747718e4ae6f5f36a56f29a51 Mon Sep 17 00:00:00 2001 From: Dieter Eickstaedt Date: Sat, 23 Sep 2023 10:56:55 +0200 Subject: refactor: Duplications reduced in order to align implementations of reading history files (#1247) --- atuin-client/src/import/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'atuin-client/src/import/mod.rs') diff --git a/atuin-client/src/import/mod.rs b/atuin-client/src/import/mod.rs index 3d38cd29..0c15c9dd 100644 --- a/atuin-client/src/import/mod.rs +++ b/atuin-client/src/import/mod.rs @@ -1,3 +1,5 @@ +use std::fs::File; +use std::io::Read; use std::path::PathBuf; use async_trait::async_trait; @@ -74,6 +76,12 @@ where } } +fn read_to_end(path: PathBuf) -> Result> { + let mut bytes = Vec::new(); + let mut f = File::open(path)?; + f.read_to_end(&mut bytes)?; + Ok(bytes) +} fn is_file(p: PathBuf) -> Result { if p.is_file() { Ok(p) -- cgit v1.3.1