aboutsummaryrefslogtreecommitdiff
path: root/src/fileutil.rs
diff options
context:
space:
mode:
authorHristo Venev <hristo@venev.name>2020-02-07 20:10:31 +0000
committerHristo Venev <hristo@venev.name>2020-02-07 20:11:50 +0000
commit1168ac0458c7e92f22d1c77bf31daea4e23ac750 (patch)
treeefff329fc504863c35d7b59955aaa20252adc2c8 /src/fileutil.rs
parentaa3fa809befbda4c28cbc84730fbe3ef8fe23c22 (diff)
Load the preshared keys on startup.
Diffstat (limited to 'src/fileutil.rs')
-rw-r--r--src/fileutil.rs17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/fileutil.rs b/src/fileutil.rs
index 2c322c4..190a7d0 100644
--- a/src/fileutil.rs
+++ b/src/fileutil.rs
@@ -82,22 +82,13 @@ pub fn update(path: &Path, data: &[u8]) -> io::Result<()> {
}
#[inline]
-pub fn load(path: &impl AsRef<Path>) -> io::Result<Option<Vec<u8>>> {
+pub fn load(path: &impl AsRef<Path>) -> io::Result<Vec<u8>> {
_load(path.as_ref())
}
-fn _load(path: &Path) -> io::Result<Option<Vec<u8>>> {
- let mut file = match fs::File::open(&path) {
- Ok(file) => file,
- Err(e) => {
- if e.kind() == io::ErrorKind::NotFound {
- return Ok(None);
- }
- return Err(e);
- }
- };
-
+fn _load(path: &Path) -> io::Result<Vec<u8>> {
+ let mut file = fs::File::open(&path)?;
let mut data = Vec::new();
io::Read::read_to_end(&mut file, &mut data)?;
- Ok(Some(data))
+ Ok(data)
}