Add option to manually swap shifts after the schedule has been generated

This commit is contained in:
2026-07-02 19:15:07 +03:00
parent 515b9aa317
commit 9d8eacfb2b
7 changed files with 550 additions and 31 deletions

View File

@@ -47,6 +47,29 @@ pub enum ExportError {
OpenFailed(String),
}
#[derive(Error, Debug, Serialize)]
#[serde(tag = "kind", content = "details")]
pub enum SwapError {
#[error("no schedule has been generated yet")]
NotGenerated,
#[error("invalid shift position: {0}")]
InvalidPosition(String),
#[error("slot has no assigned resident")]
SlotEmpty,
#[error("both slots belong to the same resident")]
SameResident,
#[error("resident not found in config")]
ResidentNotFound,
#[error("resident cannot take the target slot: negative shift or disallowed type")]
ResidentCannotTakeSlot,
#[error("swap violates same-day or toxic pair constraint")]
SameDayOrToxicPair,
#[error("swap creates a consecutive-day constraint violation")]
ConsecutiveDays,
#[error("cannot swap the same slot or slots on the same day")]
SameSlotOrDay,
}
impl Serialize for ExportError {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where