Start to implement the ClienState struct
Signed-off-by: Paul R. Tagliamonte <paul@kittycad.io>
This commit is contained in:
		
				
					committed by
					
						
						Dan Shaw
					
				
			
			
				
	
			
			
			
						parent
						
							950f27ce2a
						
					
				
				
					commit
					0ac1cbfcf9
				
			@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
use anyhow::Result;
 | 
			
		||||
 | 
			
		||||
use crate::coredump::CoreDump;
 | 
			
		||||
use crate::coredump::{AuthMachineState, ClientState, CoreDump};
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Clone)]
 | 
			
		||||
pub struct CoreDumper {}
 | 
			
		||||
@ -55,8 +55,8 @@ impl CoreDump for CoreDumper {
 | 
			
		||||
        Ok(crate::coredump::WebrtcStats::default())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn get_client_state(&self) -> Result<String> {
 | 
			
		||||
        Ok("{}".to_string())
 | 
			
		||||
    async fn get_client_state(&self) -> Result<ClientState> {
 | 
			
		||||
        Ok(ClientState::default())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn screenshot(&self) -> Result<String> {
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@ pub trait CoreDump: Clone {
 | 
			
		||||
 | 
			
		||||
    async fn get_webrtc_stats(&self) -> Result<WebrtcStats>;
 | 
			
		||||
 | 
			
		||||
    async fn get_client_state(&self) -> Result<String>;
 | 
			
		||||
    async fn get_client_state(&self) -> Result<ClientState>;
 | 
			
		||||
 | 
			
		||||
    /// Return a screenshot of the app.
 | 
			
		||||
    async fn screenshot(&self) -> Result<String>;
 | 
			
		||||
@ -115,8 +115,7 @@ pub struct AppInfo {
 | 
			
		||||
    pub pool: String,
 | 
			
		||||
 | 
			
		||||
    /// The client state (singletons and xstate)
 | 
			
		||||
    ///#[serde(skip_serializing_if = "Option::is_none")]
 | 
			
		||||
    pub client_state: String,
 | 
			
		||||
    pub client_state: ClientState,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl AppInfo {
 | 
			
		||||
@ -205,3 +204,18 @@ pub struct WebrtcStats {
 | 
			
		||||
    /// Packet jitter for this synchronizing source, measured in seconds.
 | 
			
		||||
    pub jitter: f32,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
 | 
			
		||||
#[ts(export)]
 | 
			
		||||
#[serde(rename_all = "snake_case")]
 | 
			
		||||
pub struct AuthMachineState {
 | 
			
		||||
    pub _unused: [u8; 0],
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
 | 
			
		||||
#[ts(export)]
 | 
			
		||||
#[serde(rename_all = "snake_case")]
 | 
			
		||||
pub struct ClientState {
 | 
			
		||||
    /// Internal state of the AuthMachine xstate object.
 | 
			
		||||
    pub auth_machine: AuthMachineState,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,10 @@
 | 
			
		||||
use anyhow::Result;
 | 
			
		||||
use wasm_bindgen::prelude::wasm_bindgen;
 | 
			
		||||
 | 
			
		||||
use crate::{coredump::CoreDump, wasm::JsFuture};
 | 
			
		||||
use crate::{
 | 
			
		||||
    coredump::{AuthMachineState, ClientState, CoreDump},
 | 
			
		||||
    wasm::JsFuture,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#[wasm_bindgen(module = "/../../lib/coredump.ts")]
 | 
			
		||||
extern "C" {
 | 
			
		||||
@ -128,15 +131,11 @@ impl CoreDump for CoreDumper {
 | 
			
		||||
        Ok(stats)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn get_client_state(&self) -> Result<String> {
 | 
			
		||||
        // Parse the value as a string.
 | 
			
		||||
        let client_state = "{ signletons: {}, xstate: {} }";
 | 
			
		||||
 | 
			
		||||
        //self.manager
 | 
			
		||||
        //    .get_client_state()
 | 
			
		||||
        //    .map_err(|e| anyhow::anyhow!("Failed to get response from get client state: {:?}", e));
 | 
			
		||||
 | 
			
		||||
        Ok(client_state.to_string())
 | 
			
		||||
    async fn get_client_state(&self) -> Result<ClientState> {
 | 
			
		||||
        Ok(ClientState {
 | 
			
		||||
            auth_machine: AuthMachineState { ..Default::default() },
 | 
			
		||||
            ..Default::default()
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn screenshot(&self) -> Result<String> {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user