use anyhow::Result;

use crate::request::Request;
use crate::response::Response;
use crate::utils::Values;

pub mod cookie;
pub mod file;

pub trait Session: Send + Sync {
    fn values(&mut self) -> Values;
    fn set(&mut self, key: &str, value: &str);
    fn set_values(&mut self, values: Values);
    fn get(&mut self, key: &str) -> String;
    fn remove(&mut self, key: &str);
    fn errors(&mut self) -> Values;
    fn set_error(&mut self, key: &str, value: &str);
    fn set_errors(&mut self, errors: Values);
    fn get_error(&mut self, key: &str) -> String;
    fn remove_error(&mut self, key: &str);
    fn set_old(&mut self, old: Values);
    fn old_values(&mut self) -> Values;
    fn old(&mut self, key: &str) -> String;
    fn set_flash(&mut self, key: &str, value: &str);
    fn flash(&mut self, key: &str) -> String;
    fn flashes(&mut self) -> Values;
}

pub trait SessionManager: Send + Sync {
    fn setup<'a>(&'a mut self, req: &'a mut Request, res: &'a mut Response) -> Result<()>;
    fn teardown<'a>(&'a mut self, req: &'a mut Request, res: &'a mut Response) -> Result<()>;
}