use serde::{Deserialize, Serialize}; use super::repository::{RepositoryInfo, RepositoryItem, RepositoryList}; // representation of a Model in the template. #[derive(Deserialize, Serialize)] pub struct DepotModel { pub key: String, pub name: String, pub model_url: String, pub view_only: bool, pub add_url: Option, } // representation of a Section in the template. #[derive(Deserialize, Serialize)] pub struct DepotSection { pub key: String, pub name: String, pub section_url: String, pub models: Vec, } #[derive(Serialize, Deserialize)] pub struct DepotRequest { pub path: String, } #[derive(Serialize)] pub struct DepotContext { pub base: Option, pub language_code: Option, pub language_bidi: Option, pub user: Option, // Todo: user type pub depot_url: String, pub site_url: Option, pub docsroot: Option, pub messages: Vec, // Todo: message type pub title: Option, pub subtitle: Option, pub content: String, pub request: DepotRequest, pub sections: Vec, pub item_model: Option, pub item_info: Option, pub item_list: RepositoryList, pub item: Option, } impl Default for DepotContext { fn default() -> Self { DepotContext { base: None, // TODO: what is this used for? language_code: Some("en-us".to_string()), // Default language code language_bidi: Some(false), // Default language bidi user: None, //UserType::default(), // Assuming UserType has a Default impl depot_url: "/depot".to_owned(), site_url: None, docsroot: None, messages: Vec::new(), // Empty vector for messages title: None, subtitle: None, content: String::new(), // Empty string for content sections: Vec::new(), request: DepotRequest { path: "".to_owned(), }, item_model: None, item_info: None, item_list: RepositoryList::Empty, item: None, } } }