clnrm_shared/
lib.rs

1//! Shared utilities for the Cleanroom Testing Framework
2//!
3//! This crate contains common types and utilities shared across
4//! the Cleanroom ecosystem.
5
6use serde::{Deserialize, Serialize};
7use uuid::Uuid;
8
9/// Common result type for shared operations
10pub type SharedResult<T> = Result<T, SharedError>;
11
12/// Shared error type
13#[derive(Debug, thiserror::Error)]
14pub enum SharedError {
15    #[error("Serialization error: {0}")]
16    Serialization(#[from] serde_json::Error),
17
18    #[error("UUID error: {0}")]
19    Uuid(#[from] uuid::Error),
20}
21
22/// Generate a new session ID
23pub fn generate_session_id() -> Uuid {
24    Uuid::new_v4()
25}
26
27/// Common configuration structure
28#[derive(Debug, Clone, Serialize, Deserialize)]
29pub struct SharedConfig {
30    pub session_id: Uuid,
31    pub version: String,
32}
33
34impl Default for SharedConfig {
35    fn default() -> Self {
36        Self {
37            session_id: generate_session_id(),
38            version: env!("CARGO_PKG_VERSION").to_string(),
39        }
40    }
41}