Skip to main content

surver/
lib.rs

1//! External access to the Surver server.
2use std::sync::LazyLock;
3
4use serde::{Deserialize, Serialize};
5
6#[cfg(not(target_arch = "wasm32"))]
7mod server;
8#[cfg(not(target_arch = "wasm32"))]
9pub use server::surver_main;
10
11pub const HTTP_SERVER_KEY: &str = "Server";
12pub const HTTP_SERVER_VALUE_SURFER: &str = "Surfer";
13pub const X_WELLEN_VERSION: &str = "x-wellen-version";
14pub const X_SURFER_VERSION: &str = "x-surfer-version";
15pub const SURFER_VERSION: &str = env!("CARGO_PKG_VERSION");
16pub const WELLEN_VERSION: &str = wellen::VERSION;
17
18pub const WELLEN_SURFER_DEFAULT_OPTIONS: wellen::LoadOptions = wellen::LoadOptions {
19    multi_thread: true,
20    remove_scopes_with_empty_name: true,
21};
22
23#[derive(Debug, Serialize, Deserialize)]
24pub struct SurverStatus {
25    pub wellen_version: String,
26    pub surfer_version: String,
27    pub file_infos: Vec<SurverFileInfo>,
28}
29
30#[derive(Debug, Serialize, Deserialize, Clone)]
31pub struct SurverFileInfo {
32    pub bytes: u64,
33    pub bytes_loaded: u64,
34    pub filename: String,
35    pub format: wellen::FileFormat,
36    pub reloading: bool,
37    pub last_load_ok: bool,
38    // Time for last successful load, if known
39    pub last_load_time: Option<u64>,
40}
41pub static BINCODE_OPTIONS: LazyLock<bincode::DefaultOptions> =
42    LazyLock::new(bincode::DefaultOptions::new);