qol: improve store.rs imports

This commit is contained in:
2024-04-24 06:40:09 -05:00
parent 137e747c9c
commit 9d3a68e225

View File

@@ -1,5 +1,3 @@
use std::{io::Seek, path::PathBuf};
#[cfg(not(target_os = "emscripten"))] #[cfg(not(target_os = "emscripten"))]
pub struct Store { pub struct Store {
file: std::fs::File, file: std::fs::File,
@@ -10,7 +8,7 @@ pub struct Store;
#[cfg(not(target_os = "emscripten"))] #[cfg(not(target_os = "emscripten"))]
impl Store { impl Store {
pub fn new () -> Self { pub fn new() -> Self {
let path = Store::get_path(); let path = Store::get_path();
let file = std::fs::OpenOptions::new() let file = std::fs::OpenOptions::new()
.read(true) .read(true)
@@ -21,7 +19,7 @@ impl Store {
Store { file } Store { file }
} }
fn get_path() -> PathBuf { fn get_path() -> std::path::PathBuf {
use std::env; use std::env;
let mut path = env::current_exe().unwrap(); let mut path = env::current_exe().unwrap();
path.pop(); path.pop();
@@ -38,7 +36,7 @@ impl Store {
} }
pub fn set_volume(&mut self, volume: u32) { pub fn set_volume(&mut self, volume: u32) {
use std::io::Write; use std::io::{Seek, Write};
self.file.set_len(0).unwrap(); self.file.set_len(0).unwrap();
self.file.seek(std::io::SeekFrom::Start(0)).unwrap(); self.file.seek(std::io::SeekFrom::Start(0)).unwrap();
@@ -54,7 +52,7 @@ extern "C" {
#[cfg(target_os = "emscripten")] #[cfg(target_os = "emscripten")]
impl Store { impl Store {
pub fn new () -> Self { pub fn new() -> Self {
Store Store
} }
@@ -90,4 +88,4 @@ impl Store {
String::from(c_str.to_str().unwrap()) String::from(c_str.to_str().unwrap())
} }
} }
} }