Implemented a domain layer, because the API DTO's where getting bloated.

This commit is contained in:
2026-09-26 17:22:10 +02:00
parent 04debfba7b
commit 4737bd5c81
24 changed files with 1103 additions and 538 deletions
+13 -18
View File
@@ -1,33 +1,28 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
use crate::domain;
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Direction {
In,
Out,
}
impl Direction {
pub fn as_str(&self) -> &'static str {
match self {
Self::In => "in",
Self::Out => "out",
impl From<Direction> for domain::Direction {
fn from(direction: Direction) -> Self {
match direction {
Direction::In => Self::In,
Direction::Out => Self::Out,
}
}
}
impl TryFrom<String> for Direction {
type Error = DirectionConversionError;
fn try_from(value: String) -> Result<Self, Self::Error> {
match value.as_str() {
"in" => Ok(Self::In),
"out" => Ok(Self::Out),
_ => Err(DirectionConversionError(value)),
impl From<domain::Direction> for Direction {
fn from(direction: domain::Direction) -> Self {
match direction {
domain::Direction::In => Self::In,
domain::Direction::Out => Self::Out,
}
}
}
#[derive(Debug, thiserror::Error)]
#[error("invalid direction value: {0}")]
pub struct DirectionConversionError(pub String);