pub struct ShiftCycleConfig {
pub cycle: Vec<ShiftType>,
pub cycle_length: u32,
pub reference_date: NaiveDate,
pub total_teams: u32,
}Expand description
Runtime shift cycle configuration.
The default 42-day, 6-team configuration is available via
default_config().
§Custom cycles
use shift_algorithm::{ShiftCycleConfig, ShiftType};
use chrono::NaiveDate;
let config = ShiftCycleConfig {
cycle: vec![ShiftType::Morning, ShiftType::Afternoon, ShiftType::Rest],
cycle_length: 3,
reference_date: NaiveDate::from_ymd_opt(2025, 12, 15).unwrap(),
total_teams: 1,
};Fields§
§cycle: Vec<ShiftType>The ordered list of shift types defining one full cycle.
Must have length == cycle_length.
cycle_length: u32Number of days in one full cycle (= cycle.len()).
reference_date: NaiveDateThe anchor reference date. Day 1 of the cycle falls on this date. Default: 2025-12-15.
total_teams: u32Total number of teams sharing this cycle.
Each team is offset by cycle_length / total_teams days.
Default: 6.
Implementations§
Source§impl ShiftCycleConfig
impl ShiftCycleConfig
Sourcepub fn new(
cycle: Vec<ShiftType>,
reference_date: NaiveDate,
total_teams: u32,
) -> Self
pub fn new( cycle: Vec<ShiftType>, reference_date: NaiveDate, total_teams: u32, ) -> Self
Create a new config, validating that cycle.len() == cycle_length.
§Panics
Panics if cycle.len() != cycle_length as usize.
Sourcepub fn team_phase_offset(&self, team_id: u32) -> u32
pub fn team_phase_offset(&self, team_id: u32) -> u32
Team phase offset in days.
Formula: (team_id - 1) * (cycle_length / total_teams).
For a 42-day, 6-team cycle:
- Team 1 (一值): offset 0
- Team 2 (二值): offset 7
- Team 3 (三值): offset 14
- …
- Team 6 (六值): offset 35
use shift_algorithm::cycle::default_config;
let config = default_config();
assert_eq!(config.team_phase_offset(1), 0);
assert_eq!(config.team_phase_offset(2), 7);
assert_eq!(config.team_phase_offset(6), 35);Trait Implementations§
Source§impl Clone for ShiftCycleConfig
impl Clone for ShiftCycleConfig
Source§fn clone(&self) -> ShiftCycleConfig
fn clone(&self) -> ShiftCycleConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShiftCycleConfig
impl Debug for ShiftCycleConfig
Source§impl<'de> Deserialize<'de> for ShiftCycleConfig
impl<'de> Deserialize<'de> for ShiftCycleConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ShiftCycleConfig
impl RefUnwindSafe for ShiftCycleConfig
impl Send for ShiftCycleConfig
impl Sync for ShiftCycleConfig
impl Unpin for ShiftCycleConfig
impl UnsafeUnpin for ShiftCycleConfig
impl UnwindSafe for ShiftCycleConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more