use notmuch::SearchSummary; use build_info::{VersionControl,BuildInfo}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct SearchResult { pub summary: SearchSummary, pub query: String, pub page: usize, pub results_per_page: usize, pub total: usize, } #[derive(Serialize, Deserialize, Debug)] pub struct Message {} pub mod urls { pub const MOUNT_POINT: &'static str = "/api"; pub fn cid_prefix(host: Option<&str>, cid: &str) -> String { if let Some(host) = host { format!("//{host}/api/cid/{cid}/") } else { format!("/api/cid/{cid}/") } } pub fn download_attachment(host: Option<&str>, id: &str, idx: &str, filename: &str) -> String { if let Some(host) = host { format!( "//{host}/api/download/attachment/{}/{}/{}", id, idx, filename ) } else { format!("/api/download/attachment/{}/{}/{}", id, idx, filename) } } } pub fn build_version(bi:fn()->&'static BuildInfo) -> String { fn commit(git: &Option) -> String { let Some(VersionControl::Git(git)) = git else { return String::new(); }; let mut s = vec!["-".to_string(), git.commit_short_id.clone()]; if git.dirty { s.push(".+".to_string()); } if let Some(branch) = &git.branch { s.push(format!(" ({branch})")); } s.join("") } let bi = bi(); format!("v{}{}", bi.crate_info.version, commit(&bi.version_control)).to_string() }