Moved domain logic out of the database layer, to the user app route.

This commit is contained in:
2026-10-09 14:50:39 +02:00
parent 0517ddd02e
commit 4a84c8330a
11 changed files with 141 additions and 161 deletions
+11 -10
View File
@@ -12,18 +12,19 @@ impl<T> Upsert<T> {
}
}
pub enum GuardedUpsert<T> {
Created(T),
Updated(T),
Rejected,
pub struct Upserted<T> {
pub current: T,
pub previous: Option<T>,
}
impl<T> GuardedUpsert<T> {
pub fn try_map<U, E>(self, f: impl FnOnce(T) -> Result<U, E>) -> Result<GuardedUpsert<U>, E> {
Ok(match self {
Self::Created(value) => GuardedUpsert::Created(f(value)?),
Self::Updated(value) => GuardedUpsert::Updated(f(value)?),
Self::Rejected => GuardedUpsert::Rejected,
impl<T> Upserted<T> {
pub fn try_map<U, E>(self, mut f: impl FnMut(T) -> Result<U, E>) -> Result<Upserted<U>, E> {
Ok(Upserted {
current: f(self.current)?,
previous: match self.previous {
Some(value) => Some(f(value)?),
None => None,
},
})
}
}