Improved tauri events type safety

This commit is contained in:
2026-03-07 14:48:19 +08:00
parent f372e86457
commit f65d837841
20 changed files with 215 additions and 141 deletions

View File

@@ -41,4 +41,4 @@ pub struct DollDto {
pub configuration: DollConfigurationDto,
pub created_at: String,
pub updated_at: String,
}
}

View File

@@ -0,0 +1,79 @@
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use super::dolls::DollDto;
use super::friends::UserBasicDto;
use crate::services::presence_modules::models::PresenceStatus;
#[derive(Clone, Serialize, Deserialize, Debug, TS)]
#[serde(rename_all = "lowercase")]
#[ts(export)]
pub enum UserStatusState {
Idle,
Resting,
}
#[derive(Clone, Serialize, Deserialize, Debug, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct UserStatusPayload {
pub presence_status: PresenceStatus,
pub state: UserStatusState,
}
#[derive(Clone, Serialize, Deserialize, Debug, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct FriendUserStatusPayload {
pub user_id: String,
pub status: UserStatusPayload,
}
#[derive(Clone, Serialize, Deserialize, Debug, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct FriendDisconnectedPayload {
pub user_id: String,
}
#[derive(Clone, Serialize, Deserialize, Debug, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct FriendActiveDollChangedPayload {
pub friend_id: String,
pub doll: Option<DollDto>,
}
#[derive(Clone, Serialize, Deserialize, Debug, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct FriendRequestReceivedPayload {
pub id: String,
pub sender: UserBasicDto,
pub created_at: String,
}
#[derive(Clone, Serialize, Deserialize, Debug, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct FriendRequestAcceptedPayload {
pub id: String,
pub friend: UserBasicDto,
pub accepted_at: String,
}
#[derive(Clone, Serialize, Deserialize, Debug, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct FriendRequestDeniedPayload {
pub id: String,
pub denier: UserBasicDto,
pub denied_at: String,
}
#[derive(Clone, Serialize, Deserialize, Debug, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct UnfriendedPayload {
pub friend_id: String,
}

View File

@@ -25,4 +25,4 @@ pub enum HealthError {
NonOkStatus(String),
#[error("health response decode failed: {0}")]
Decode(reqwest::Error),
}
}

View File

@@ -1,7 +1,8 @@
pub mod app_data;
pub mod remote_error;
pub mod dolls;
pub mod event_payloads;
pub mod friends;
pub mod health;
pub mod interaction;
pub mod remote_error;
pub mod user;