1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Functions for getting core dump information via local rust.

use anyhow::Result;
use serde_json::Value as JValue;

use crate::coredump::CoreDump;

#[derive(Debug, Clone)]
pub struct CoreDumper {}

impl CoreDumper {
    pub fn new() -> Self {
        CoreDumper {}
    }
}

impl Default for CoreDumper {
    fn default() -> Self {
        Self::new()
    }
}

#[async_trait::async_trait(?Send)]
impl CoreDump for CoreDumper {
    fn token(&self) -> Result<String> {
        Ok(std::env::var("KITTYCAD_API_TOKEN").unwrap_or_default())
    }

    fn base_api_url(&self) -> Result<String> {
        Ok("https://api.zoo.dev".to_string())
    }

    fn version(&self) -> Result<String> {
        Ok(env!("CARGO_PKG_VERSION").to_string())
    }

    fn pool(&self) -> Result<String> {
        Ok("".to_owned())
    }

    async fn os(&self) -> Result<crate::coredump::OsInfo> {
        Ok(crate::coredump::OsInfo {
            platform: Some(std::env::consts::OS.to_string()),
            arch: Some(std::env::consts::ARCH.to_string()),
            version: None,
            browser: None,
        })
    }

    fn is_tauri(&self) -> Result<bool> {
        Ok(false)
    }

    async fn get_webrtc_stats(&self) -> Result<crate::coredump::WebrtcStats> {
        // TODO: we could actually implement this.
        Ok(crate::coredump::WebrtcStats::default())
    }

    async fn get_client_state(&self) -> Result<JValue> {
        Ok(JValue::default())
    }

    async fn screenshot(&self) -> Result<String> {
        // Take a screenshot of the engine.
        todo!()
    }
}