ginger_shared_rs/rocket_models.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize)]
5pub struct RealtimeMessage {
6 pub topic: String,
7 pub payload: String,
8}
9
10// Implement the `ToString` trait for the struct
11impl ToString for RealtimeMessage {
12 fn to_string(&self) -> String {
13 // Convert the struct to a JSON string using serde_json
14 serde_json::to_string(self).unwrap_or_else(|_| "Failed to serialize".to_string())
15 }
16}
17
18#[derive(Debug, Deserialize, Serialize, JsonSchema)]
19pub struct MessageResponse {
20 /// This is a message from the server.
21 pub message: String,
22}