openlark_analytics/common/
mod.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct SearchResult {
8 pub id: String,
10 pub title: String,
12 pub summary: Option<String>,
14 pub result_type: String,
16 pub score: f64,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct SearchStats {
23 pub total: u32,
25 pub query_time_ms: u32,
27 pub page_count: u32,
29}
30
31#[cfg(test)]
32#[allow(unused_imports)]
33mod tests {
34
35 #[test]
36 fn test_serialization_roundtrip() {
37 let json = r#"{"test": "value"}"#;
39 assert!(serde_json::from_str::<serde_json::Value>(json).is_ok());
40 }
41
42 #[test]
43 fn test_deserialization_from_json() {
44 let json = r#"{"field": "data"}"#;
46 let value: serde_json::Value = serde_json::from_str(json).expect("JSON 反序列化失败");
47 assert_eq!(value["field"], "data");
48 }
49}