This commit is contained in:
2023-05-17 17:31:48 +02:00
parent 04abb53f4a
commit 4b4a61d3bb
4 changed files with 83 additions and 59 deletions

View File

@@ -12,6 +12,7 @@ use futures::TryStreamExt;
pub enum Error {
SqlError { description: String },
UuidError { description: String },
NotFoundError { description: String },
}
impl fmt::Display for Error {
@@ -23,6 +24,9 @@ impl fmt::Display for Error {
Self::UuidError { description } => {
write!(f, "UUID error: {description}")
}
Self::NotFoundError { description } => {
write!(f, "Not found: {description}")
}
}
}
}
@@ -78,12 +82,12 @@ impl TryFrom<SqliteRow> for Trip {
}
}
#[derive(Debug)]
pub struct Category {
pub id: Uuid,
pub name: String,
pub description: String,
items: Option<Vec<Item>>,
pub active: bool,
}
impl TryFrom<SqliteRow> for Category {
@@ -99,7 +103,6 @@ impl TryFrom<SqliteRow> for Category {
name: name.to_string(),
description: description.to_string(),
items: None,
active: false,
})
}
}
@@ -138,6 +141,7 @@ impl<'a> Category {
}
}
#[derive(Debug)]
pub struct Item {
pub id: Uuid,
pub name: String,