ratamath 0.1.0

A simple math training TUI game built with Ratatui( not final version)
#![allow(unused)]
use crate::file_manager;
use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};

#[derive(Default, Serialize, Deserialize)]
pub struct Statictic {
    pub days: Vec<DaySt>,
    pub total_games: usize,
    pub total_corect: usize,
    pub total_wrong: usize,
    pub total_play_time: f32,
}
#[derive(Default, Serialize, Deserialize)]
pub struct DaySt {
    pub games: usize,
    pub corect: usize,
    pub wrong: usize,
    pub play_time: f32,
}

impl Statictic {
    pub fn load() -> Result<Self> {
        let str_st = file_manager::load_statistic_to_str();
        match str_st {
            Ok(content) => {
                let statictic = toml::from_str(&content)?;
                Ok(statictic)
            }
            Err(e) => {
                let st = Statictic::default();
                Ok(st)
            }
        }
    }
    pub fn save(&self) -> Result<()> {
        let string_content =
            toml::to_string_pretty(&self).context("couldnt parse statictic to string")?;
        file_manager::save_statistic(&string_content)?;
        Ok(())
    }
}