mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2025-12-11 20:15:30 +01:00
- Enhanced the `Event` enum documentation for clarity on its purpose. - Modified the Swift client generation script to create event samples for enum generation. - Updated the Swift client to utilize the new `EventElement` type for event handling. - Improved error handling and logging in the event subscription process. - Refactored the types generated for Swift to align with the new event structure.
30 lines
780 B
Rust
30 lines
780 B
Rust
//! Test how Event enums serialize to understand the JSON format
|
|
|
|
use sd_core::infra::event::Event;
|
|
use serde_json;
|
|
use std::path::PathBuf;
|
|
use uuid::Uuid;
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
// Test simple enum variant
|
|
let event1 = Event::CoreStarted;
|
|
println!("CoreStarted: {}", serde_json::to_string(&event1)?);
|
|
|
|
// Test struct-like enum variant
|
|
let event2 = Event::LibraryCreated {
|
|
id: Uuid::new_v4(),
|
|
name: "Test Library".to_string(),
|
|
path: PathBuf::from("/test/path"),
|
|
};
|
|
println!("LibraryCreated: {}", serde_json::to_string(&event2)?);
|
|
|
|
// Test job event
|
|
let event3 = Event::JobStarted {
|
|
job_id: "test-job-123".to_string(),
|
|
job_type: "Indexing".to_string(),
|
|
};
|
|
println!("JobStarted: {}", serde_json::to_string(&event3)?);
|
|
|
|
Ok(())
|
|
}
|