Complete backtracking, restriction violations, split model.rs into multiple files

This commit is contained in:
2026-01-11 10:44:25 +02:00
parent e11e1376eb
commit 53f8695572
11 changed files with 998 additions and 489 deletions

46
src-tauri/src/resident.rs Normal file
View File

@@ -0,0 +1,46 @@
use serde::{Deserialize, Serialize};
use crate::{
schedule::ShiftType,
slot::{Day, Slot},
};
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Resident {
pub id: String,
pub name: String,
pub negative_shifts: Vec<Day>,
pub manual_shifts: Vec<Slot>,
pub max_shifts: Option<usize>,
pub allowed_types: Vec<ShiftType>,
pub reduced_load: bool,
}
impl Resident {
pub fn new(id: &str, name: &str) -> Self {
Self {
id: id.to_string(),
name: name.to_string(),
negative_shifts: Vec::new(),
manual_shifts: Vec::new(),
max_shifts: None,
allowed_types: vec![
ShiftType::OpenFirst,
ShiftType::OpenSecond,
ShiftType::Closed,
],
reduced_load: false,
}
}
pub fn with_max_shifts(mut self, max_shifts: usize) -> Self {
self.max_shifts = Some(max_shifts);
self
}
pub fn with_reduced_load(mut self) -> Self {
self.reduced_load = true;
self
}
}