Skip to main content

ResolvedBlockBounds

Struct ResolvedBlockBounds 

Source
pub struct ResolvedBlockBounds { /* private fields */ }
Expand description

Pre-resolved per-block bound override table for every block-eligible entity family, across all stages and blocks.

Every family Vec is indexed (entity_idx * n_stages + stage_idx) * max_blocks + block_idx, and is independently lazy: a family stays empty until a row actually resolves to a cell in that family (via its own <family>_override_mut), so a study with a block row in only one family never allocates the other four. An empty table (ResolvedBlockBounds::empty) is the state for every study with no block_id bound row at all; every reader then returns the family default and every writer returns None.

§Examples

use cobre_core::resolved::ResolvedBlockBounds;

let empty = ResolvedBlockBounds::empty();
assert!(empty.is_empty());
assert_eq!(empty.thermal_override(3, 7, 2).max_generation_mw, None);

Implementations§

Source§

impl ResolvedBlockBounds

Source

pub fn empty() -> Self

Create an empty per-block override table; every reader returns the family default and every writer returns None.

§Examples
use cobre_core::resolved::ResolvedBlockBounds;

let t = ResolvedBlockBounds::empty();
assert!(t.is_empty());
assert_eq!(t.hydro_override(5, 3, 2).min_turbined_m3s, None);
Source

pub fn new(counts: &BlockBoundsCountsSpec) -> Self

Store the table’s dimensions; every family Vec starts empty — <family>_override_mut grows its own family to full size on its first successful write, so a family with zero applied rows stays empty (and is_empty stays true while every family does).

Source

pub fn hydro_override( &self, hydro_idx: usize, stage_idx: usize, block_idx: usize, ) -> HydroBlockOverride

Look up the hydro per-block override at (hydro_idx, stage_idx, block_idx). Returns HydroBlockOverride::default (all None) when the table is empty or any index is out of range.

Source

pub fn hydro_override_mut( &mut self, hydro_idx: usize, stage_idx: usize, block_idx: usize, ) -> Option<&mut HydroBlockOverride>

Return a mutable handle to the hydro per-block override cell, growing this family to full size on its first call, or None when the table is empty or any index is out of range.

Source

pub fn thermal_override( &self, thermal_idx: usize, stage_idx: usize, block_idx: usize, ) -> ThermalBlockOverride

Look up the thermal per-block override at (thermal_idx, stage_idx, block_idx). Returns ThermalBlockOverride::default (all None) when the table is empty or any index is out of range.

Source

pub fn thermal_override_mut( &mut self, thermal_idx: usize, stage_idx: usize, block_idx: usize, ) -> Option<&mut ThermalBlockOverride>

Return a mutable handle to the thermal per-block override cell, growing this family to full size on its first call, or None when the table is empty or any index is out of range.

Source

pub fn line_override( &self, line_idx: usize, stage_idx: usize, block_idx: usize, ) -> LineBlockOverride

Look up the line per-block override at (line_idx, stage_idx, block_idx). Returns LineBlockOverride::default (all None) when the table is empty or any index is out of range.

Source

pub fn line_override_mut( &mut self, line_idx: usize, stage_idx: usize, block_idx: usize, ) -> Option<&mut LineBlockOverride>

Return a mutable handle to the line per-block override cell, growing this family to full size on its first call, or None when the table is empty or any index is out of range.

Source

pub fn pumping_override( &self, pumping_idx: usize, stage_idx: usize, block_idx: usize, ) -> PumpingBlockOverride

Look up the pumping per-block override at (pumping_idx, stage_idx, block_idx). Returns PumpingBlockOverride::default (all None) when the table is empty or any index is out of range.

Source

pub fn pumping_override_mut( &mut self, pumping_idx: usize, stage_idx: usize, block_idx: usize, ) -> Option<&mut PumpingBlockOverride>

Return a mutable handle to the pumping per-block override cell, growing this family to full size on its first call, or None when the table is empty or any index is out of range.

Source

pub fn contract_override( &self, contract_idx: usize, stage_idx: usize, block_idx: usize, ) -> ContractBlockOverride

Look up the contract per-block override at (contract_idx, stage_idx, block_idx). Returns ContractBlockOverride::default (all None) when the table is empty or any index is out of range.

Source

pub fn contract_override_mut( &mut self, contract_idx: usize, stage_idx: usize, block_idx: usize, ) -> Option<&mut ContractBlockOverride>

Return a mutable handle to the contract per-block override cell, growing this family to full size on its first call, or None when the table is empty or any index is out of range.

Source

pub fn is_empty(&self) -> bool

Returns true when every family table is empty.

Trait Implementations§

Source§

impl Clone for ResolvedBlockBounds

Source§

fn clone(&self) -> ResolvedBlockBounds

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ResolvedBlockBounds

Source§

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

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

impl Default for ResolvedBlockBounds

Source§

fn default() -> Self

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

impl PartialEq for ResolvedBlockBounds

Source§

fn eq(&self, other: &ResolvedBlockBounds) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ResolvedBlockBounds

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.