34 lines
1.3 KiB
Rust
34 lines
1.3 KiB
Rust
|
|
//! Infrastructure entities for database persistence.
|
||
|
|
//!
|
||
|
|
//! This module defines entities that directly map to database tables,
|
||
|
|
//! providing a clear separation between the persistence layer and the
|
||
|
|
//! domain layer. These entities represent raw database records without
|
||
|
|
//! domain validation or business logic.
|
||
|
|
//!
|
||
|
|
//! # Conversion Pattern
|
||
|
|
//!
|
||
|
|
//! Infrastructure entities implement `TryFrom` traits to convert between
|
||
|
|
//! database records and domain types:
|
||
|
|
//!
|
||
|
|
//! ```rust
|
||
|
|
//! # use sta::domain::relay::types::{RelayId, RelayLabel};
|
||
|
|
//! # use sta::infrastructure::persistence::entities::relay_label_record::RelayLabelRecord;
|
||
|
|
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||
|
|
//! // Database Record -> Domain Types
|
||
|
|
//! // ... from database
|
||
|
|
//! let record: RelayLabelRecord = RelayLabelRecord { relay_id: 2, label: "label".to_string() };
|
||
|
|
//! let (relay_id, relay_label): (RelayId, RelayLabel) = record.try_into()?;
|
||
|
|
//!
|
||
|
|
//! // Domain Types -> Database Record
|
||
|
|
//! let domain_record= RelayLabelRecord::new(relay_id, &relay_label);
|
||
|
|
//! # Ok(())
|
||
|
|
//! # }
|
||
|
|
//! ```
|
||
|
|
|
||
|
|
/// Database entity for relay labels.
|
||
|
|
///
|
||
|
|
/// This module contains the `RelayLabelRecord` struct which represents
|
||
|
|
/// a single row in the `RelayLabels` database table, along with conversion
|
||
|
|
/// traits to and from domain types.
|
||
|
|
pub mod relay_label_record;
|