dalsie cvicenie
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
use std::fs;
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, PartialEq, Clone)]
|
||||
pub enum Zaner {
|
||||
@@ -69,3 +70,19 @@ impl fmt::Display for Stav {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Filmoteka {
|
||||
pub fn nacitaj_zo_suboru(cesta: &std::path::PathBuf) -> Option<Filmoteka> {
|
||||
let raw = fs::read_to_string(cesta).ok()?;
|
||||
let result = serde_json::from_str(&raw).ok();
|
||||
result
|
||||
}
|
||||
|
||||
pub fn uloz_do_suboru(&self, cesta: &std::path::PathBuf) -> bool {
|
||||
let Ok(json) = serde_json::to_string_pretty(&self) else {
|
||||
return false;
|
||||
};
|
||||
fs::write(cesta, json).is_ok()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user