pub struct ActivityTimeConstraint {
pub earliest_start_ms: Option<i64>,
pub latest_start_ms: Option<i64>,
pub earliest_end_ms: Option<i64>,
pub latest_end_ms: Option<i64>,
pub constraint_type: ConstraintType,
pub penalty_per_ms: f64,
}Expand description
Time constraint for an activity.
Unlike calendar TimeWindow (which models resource
availability), this struct represents scheduling-level boundaries:
earliest/latest start and end times, optionally with penalties.
§Examples
use u_schedule::models::time_constraints::{ActivityTimeConstraint, ConstraintType};
// Hard deadline: must finish by 5000 ms
let c = ActivityTimeConstraint::deadline(5000);
assert!(c.check_violation(0, 4000).is_none());
assert!(c.check_violation(0, 6000).is_some());Fields§
§earliest_start_ms: Option<i64>Earliest allowed start time (ms).
latest_start_ms: Option<i64>Latest allowed start time (ms).
earliest_end_ms: Option<i64>Earliest allowed end time (ms).
latest_end_ms: Option<i64>Latest allowed end time (ms) — due date.
constraint_type: ConstraintTypeHard or soft constraint.
penalty_per_ms: f64Penalty per millisecond of violation (for soft constraints).
Implementations§
Source§impl ActivityTimeConstraint
impl ActivityTimeConstraint
Sourcepub fn bounded(start_ms: i64, end_ms: i64) -> Self
pub fn bounded(start_ms: i64, end_ms: i64) -> Self
Creates a constraint with start/end boundaries.
Sourcepub fn with_earliest_start(self, ms: i64) -> Self
pub fn with_earliest_start(self, ms: i64) -> Self
Sets earliest start.
Sourcepub fn with_latest_start(self, ms: i64) -> Self
pub fn with_latest_start(self, ms: i64) -> Self
Sets latest start.
Sourcepub fn with_due_date(self, ms: i64) -> Self
pub fn with_due_date(self, ms: i64) -> Self
Sets latest end (due date).
Sourcepub fn check_violation(
&self,
start_ms: i64,
end_ms: i64,
) -> Option<TimeWindowViolation>
pub fn check_violation( &self, start_ms: i64, end_ms: i64, ) -> Option<TimeWindowViolation>
Checks if a scheduled time violates the constraint.
Returns None if no violation, or a TimeWindowViolation with details.
Trait Implementations§
Source§impl Clone for ActivityTimeConstraint
impl Clone for ActivityTimeConstraint
Source§fn clone(&self) -> ActivityTimeConstraint
fn clone(&self) -> ActivityTimeConstraint
Returns a duplicate of the value. Read more
1.0.0 · 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 ActivityTimeConstraint
impl Debug for ActivityTimeConstraint
Source§impl Default for ActivityTimeConstraint
impl Default for ActivityTimeConstraint
Source§impl<'de> Deserialize<'de> for ActivityTimeConstraint
impl<'de> Deserialize<'de> for ActivityTimeConstraint
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 ActivityTimeConstraint
impl RefUnwindSafe for ActivityTimeConstraint
impl Send for ActivityTimeConstraint
impl Sync for ActivityTimeConstraint
impl Unpin for ActivityTimeConstraint
impl UnsafeUnpin for ActivityTimeConstraint
impl UnwindSafe for ActivityTimeConstraint
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