pjson_rs/application/mod.rs
1//! Application layer - Use cases and orchestration
2//!
3//! Implements CQRS pattern with separate command and query handlers.
4//! Orchestrates domain logic and infrastructure concerns.
5
6pub mod commands;
7pub mod dto;
8pub mod handlers;
9pub mod queries;
10pub mod shared;
11
12pub use commands::*;
13pub use queries::*;
14pub use shared::AdjustmentUrgency;
15
16/// Application Result type
17pub type ApplicationResult<T> = Result<T, ApplicationError>;
18
19/// Application-specific errors
20#[derive(Debug, thiserror::Error)]
21pub enum ApplicationError {
22 /// Wraps a domain-layer error that bubbled up to the application boundary.
23 #[error("Domain error: {0}")]
24 Domain(#[from] crate::domain::DomainError),
25
26 /// Input failed validation before any domain logic ran.
27 #[error("Validation error: {0}")]
28 Validation(String),
29
30 /// Caller is not authorized to perform the requested operation.
31 #[error("Authorization error: {0}")]
32 Authorization(String),
33
34 /// A concurrent operation conflicted with the current request.
35 #[error("Concurrency error: {0}")]
36 Concurrency(String),
37
38 /// Requested entity does not exist.
39 #[error("Not found: {0}")]
40 NotFound(String),
41
42 /// Operation conflicted with the current state of the resource.
43 #[error("Conflict: {0}")]
44 Conflict(String),
45
46 /// Generic application-layer logic error not covered by other variants.
47 #[error("Application logic error: {0}")]
48 Logic(String),
49}