pub struct NodeBudget {
pub layer1_max: usize,
pub layer2_max: usize,
pub layer3_max: usize,
pub layer1_count: usize,
pub layer2_count: usize,
pub layer3_count: usize,
}Expand description
Per-layer node budget allocation and tracking.
Fields§
§layer1_max: usizeMaximum nodes allowed for Layer 1 (Governance).
layer2_max: usizeMaximum nodes allowed for Layer 2 (Process).
layer3_max: usizeMaximum nodes allowed for Layer 3 (Accounting).
layer1_count: usizeCurrent count for Layer 1.
layer2_count: usizeCurrent count for Layer 2.
layer3_count: usizeCurrent count for Layer 3.
Implementations§
Source§impl NodeBudget
impl NodeBudget
Sourcepub fn new(max_nodes: usize) -> Self
pub fn new(max_nodes: usize) -> Self
Create a budget with the given total max nodes. Default allocation: L1 gets 20%, L3 gets 10%, L2 gets remainder (70%).
Sourcepub fn can_add(&self, layer: HypergraphLayer) -> bool
pub fn can_add(&self, layer: HypergraphLayer) -> bool
Check if a layer can accept more nodes.
Sourcepub fn record_add(&mut self, layer: HypergraphLayer)
pub fn record_add(&mut self, layer: HypergraphLayer)
Record a node addition.
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Total nodes across all layers.
Sourcepub fn suggest(
&self,
l1_demand: usize,
l2_demand: usize,
l3_demand: usize,
) -> NodeBudgetSuggestion
pub fn suggest( &self, l1_demand: usize, l2_demand: usize, l3_demand: usize, ) -> NodeBudgetSuggestion
Compute a suggested budget allocation based on actual demand per layer.
Each layer gets at least its demand (up to its current max). Surplus from layers that need less than their max is redistributed proportionally to layers that need more than their max.
Sourcepub fn rebalance(
&mut self,
l1_demand: usize,
l2_demand: usize,
l3_demand: usize,
)
pub fn rebalance( &mut self, l1_demand: usize, l2_demand: usize, l3_demand: usize, )
Rebalance the budget based on actual demand per layer.
Each layer gets at least its demand (capped at the total budget). Surplus from low-demand layers is redistributed proportionally to layers with unsatisfied demand. If no layer has unsatisfied demand, surplus goes to L2 (the largest consumer by convention).
Trait Implementations§
Source§impl Clone for NodeBudget
impl Clone for NodeBudget
Source§fn clone(&self) -> NodeBudget
fn clone(&self) -> NodeBudget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NodeBudget
impl Debug for NodeBudget
Source§impl Default for NodeBudget
impl Default for NodeBudget
Source§fn default() -> NodeBudget
fn default() -> NodeBudget
Source§impl<'de> Deserialize<'de> for NodeBudget
impl<'de> Deserialize<'de> for NodeBudget
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>,
Auto Trait Implementations§
impl Freeze for NodeBudget
impl RefUnwindSafe for NodeBudget
impl Send for NodeBudget
impl Sync for NodeBudget
impl Unpin for NodeBudget
impl UnsafeUnpin for NodeBudget
impl UnwindSafe for NodeBudget
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.