pub struct Target {
pub at: Tick,
pub min: Level,
}Expand description
A minimum level the timeline must have at one tick, for example the battery reserve required at the end of a sol so the rover survives the night.
Unlike the Bounds, which hold at every tick, a target holds at at
only: activities after at may draw the level lower again. The level at at includes
every impact at at. Targets take part in every check, so
Timeline::first_violation, Plan::fits
and Plan::earliest_start reject schedules that miss one; a
miss is reported as Bound::BelowTarget.
§Examples
use resource_timeline::{ActivityId, Bound, Bounds, Impact, Target, Timeline};
// A sol lasts 100 ticks; 40 units must be left at its end.
let mut battery = Timeline::depletable(0, 100, Bounds::new(10, 100)?, 8)?;
battery.add_target(Target { at: 100, min: 40 })?;
battery.add(ActivityId(1), Impact::Rate { start: 20, end: 90, per_tick: -1 })?;
let violation = battery.first_violation()?.expect("the end-of-sol reserve is missed");
assert_eq!((violation.at, violation.level), (100, 30));
assert_eq!(violation.bound, Bound::BelowTarget(40));Fields§
§at: TickThe tick at which the level is checked. Not before the timeline start.
min: LevelThe lowest allowed level at at.
Trait Implementations§
impl Copy for Target
Source§impl<'de> Deserialize<'de> for Target
impl<'de> Deserialize<'de> for Target
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
impl Eq for Target
Source§impl Ord for Target
impl Ord for Target
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Target
impl PartialOrd for Target
impl StructuralPartialEq for Target
Auto Trait Implementations§
impl Forget for Target
impl Freeze for Target
impl Move for Target
impl RefUnwindSafe for Target
impl Send for Target
impl Sync for Target
impl Unpin for Target
impl UnsafeUnpin for Target
impl UnwindSafe for Target
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