dalsie cvicenie

This commit is contained in:
Priec
2026-02-15 19:53:04 +01:00
parent af4d960262
commit f8814e7e1a
4 changed files with 1125 additions and 0 deletions

View File

@@ -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()
}
}