Improved tauri events type safety
This commit is contained in:
@@ -41,4 +41,4 @@ pub struct DollDto {
|
||||
pub configuration: DollConfigurationDto,
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
}
|
||||
}
|
||||
|
||||
79
src-tauri/src/models/event_payloads.rs
Normal file
79
src-tauri/src/models/event_payloads.rs
Normal 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,
|
||||
}
|
||||
@@ -25,4 +25,4 @@ pub enum HealthError {
|
||||
NonOkStatus(String),
|
||||
#[error("health response decode failed: {0}")]
|
||||
Decode(reqwest::Error),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user