Skip to main content

ActivityTimeConstraint

Struct ActivityTimeConstraint 

Source
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: ConstraintType

Hard or soft constraint.

§penalty_per_ms: f64

Penalty per millisecond of violation (for soft constraints).

Implementations§

Source§

impl ActivityTimeConstraint

Source

pub fn new() -> Self

Creates an empty (unconstrained) time constraint.

Source

pub fn bounded(start_ms: i64, end_ms: i64) -> Self

Creates a constraint with start/end boundaries.

Source

pub fn deadline(deadline_ms: i64) -> Self

Creates a hard deadline (must complete by).

Source

pub fn release(release_ms: i64) -> Self

Creates a release time (cannot start before).

Source

pub fn hard(self) -> Self

Sets as hard constraint.

Source

pub fn soft(self, penalty_per_ms: f64) -> Self

Sets as soft constraint with penalty.

Source

pub fn with_earliest_start(self, ms: i64) -> Self

Sets earliest start.

Source

pub fn with_latest_start(self, ms: i64) -> Self

Sets latest start.

Source

pub fn with_due_date(self, ms: i64) -> Self

Sets latest end (due date).

Source

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

Source§

fn clone(&self) -> ActivityTimeConstraint

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActivityTimeConstraint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ActivityTimeConstraint

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ActivityTimeConstraint

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ActivityTimeConstraint

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,