use template
This commit is contained in:
16
src/data.rs
16
src/data.rs
@@ -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)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user