Complete backtracking, restriction violations, split model.rs into multiple files
This commit is contained in:
46
src-tauri/src/resident.rs
Normal file
46
src-tauri/src/resident.rs
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user