use template

This commit is contained in:
Mark
2025-07-21 13:55:21 +02:00
parent 80a86e9f8a
commit 19f51c5732
6 changed files with 632 additions and 160 deletions

View File

@@ -2,22 +2,32 @@ use std::time::Instant;
use tokio::sync::{Mutex, MutexGuard};
use crate::status::Status;
use crate::{status::Status, template::Template};
pub struct Data {
pub int_html: String,
pub globals: Vec<String>,
pub index: Template,
pub status: Mutex<Status>,
pub status_updated: Mutex<(Instant, bool)>,
}
#[allow(dead_code)]
impl Data {
pub fn new_sync() -> Self {
pub fn new_sync(int_html: String, index: Template, globals: Vec<String>) -> Self {
Self {
int_html,
index,
globals,
status: Mutex::new(Status::query_sync(false)),
status_updated: Mutex::new((Instant::now(), false)),
}
}
pub async fn new_async() -> Self {
pub async fn new_async(int_html: String, index: Template, globals: Vec<String>) -> Self {
Self {
int_html,
index,
globals,
status: Mutex::new(Status::query_async(false).await),
status_updated: Mutex::new((Instant::now(), false)),
}