Moved server, added backend structs and added ui elements.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
pub mod models;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
}
|
||||
@@ -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>,
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod origin;
|
||||
pub mod article;
|
||||
pub mod variant;
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct Variant {
|
||||
pub id: usize,
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user