working example
This commit is contained in:
parent
aaf9781fe8
commit
e69bcfc23d
18 changed files with 1290 additions and 252 deletions
26
cli/src/history.rs
Normal file
26
cli/src/history.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use std::fd::{File, OpenOptions};
|
||||
use std::io::{BufReader, BufWriter, Read, Write};
|
||||
use xdg::BaseDirectories;
|
||||
|
||||
pub struct History(File);
|
||||
|
||||
impl History {
|
||||
pub fn open(serie: spond_api::SeriesId) -> std::io::Result<Self> {
|
||||
let xdg_dirs = BaseDirectories::with_prefix(env!("CARGO_PKG_NAME"));
|
||||
let path = xdg_dirs.place_state_file(format!("{}.bin", serie))?;
|
||||
|
||||
let file = OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.read(true)
|
||||
.open(&path)?;
|
||||
|
||||
Ok(Self(file))
|
||||
}
|
||||
|
||||
pub fn append<I>(&mut self, selected: usize, ids: I) -> io::Result<()>
|
||||
where
|
||||
I: IntoIterator,
|
||||
I::Item: Into<u128>,
|
||||
I::IntoIter: ExactSizeIterator,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue