Moved server, added backend structs and added ui elements.

This commit is contained in:
2026-01-15 02:53:47 +01:00
parent 25a47bbce9
commit 0d5fef7fbb
19 changed files with 3355 additions and 123 deletions
+11
View File
@@ -0,0 +1,11 @@
pub mod models;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
+14
View File
@@ -0,0 +1,14 @@
use serde::{Deserialize, Serialize};
use crate::models::origin::Origin;
use crate::models::variant::Variant;
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Article {
pub id: usize,
pub name: String,
pub bio: bool,
pub origin: Origin,
pub description: Option<String>,
pub ingredients: Option<String>,
pub variants: Vec<Variant>,
}
+3
View File
@@ -0,0 +1,3 @@
pub mod origin;
pub mod article;
pub mod variant;
+31
View File
@@ -0,0 +1,31 @@
use std::fmt;
use std::fmt::Formatter;
use serde::{Deserialize, Serialize};
#[repr(i32)]
#[derive(Deserialize, Serialize, Copy, Clone, PartialEq, sqlx::Type)]
pub enum Origin {
EU,
NEU,
EUnEU,
}
fn to_string(unit: Origin, f: &mut Formatter) -> fmt::Result {
match unit {
Origin::EU => write!(f, "EU"),
Origin::NEU => write!(f, "Nicht EU"),
Origin::EUnEU => write!(f, "EU / Nicht EU"),
}
}
impl fmt::Debug for Origin {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
to_string(*self, f)
}
}
impl fmt::Display for Origin {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
to_string(*self, f)
}
}
+7
View File
@@ -0,0 +1,7 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Variant {
pub id: usize,
}