pub struct ResourceAllocation {
pub strategy: ResourceAllocationStrategy,
pub budget: ResourceBudget,
pub used_tokens: u64,
pub used_time_ms: u64,
pub used_cost_cents: f64,
pub children_spawned: u32,
pub current_depth: u32,
}Expand description
ResourceAllocation - Allocated resources for an execution @see packages/enact-schemas/src/execution.schemas.ts - resourceAllocationSchema
Fields§
§strategy: ResourceAllocationStrategyAllocation strategy used
budget: ResourceBudgetBudget for this allocation
used_tokens: u64Currently used tokens
used_time_ms: u64Currently used time in milliseconds
used_cost_cents: f64Currently used cost in cents
children_spawned: u32Number of children spawned
current_depth: u32Current discovery depth
Implementations§
Source§impl ResourceAllocation
impl ResourceAllocation
Sourcepub fn new(strategy: ResourceAllocationStrategy, budget: ResourceBudget) -> Self
pub fn new(strategy: ResourceAllocationStrategy, budget: ResourceBudget) -> Self
Create a new allocation with a budget
Sourcepub fn can_spawn_child(&self) -> bool
pub fn can_spawn_child(&self) -> bool
Check if we can spawn another child
Sourcepub fn can_discover_deeper(&self) -> bool
pub fn can_discover_deeper(&self) -> bool
Check if we can go deeper in discovery
Sourcepub fn has_token_budget(&self, tokens: u64) -> bool
pub fn has_token_budget(&self, tokens: u64) -> bool
Check if we have token budget remaining
Sourcepub fn has_time_budget(&self, time_ms: u64) -> bool
pub fn has_time_budget(&self, time_ms: u64) -> bool
Check if we have time budget remaining
Sourcepub fn record_tokens(&mut self, tokens: u64)
pub fn record_tokens(&mut self, tokens: u64)
Record token usage
Sourcepub fn record_time(&mut self, time_ms: u64)
pub fn record_time(&mut self, time_ms: u64)
Record time usage
Sourcepub fn record_child_spawn(&mut self)
pub fn record_child_spawn(&mut self)
Record child spawn
Sourcepub fn increment_depth(&mut self)
pub fn increment_depth(&mut self)
Increment depth
Sourcepub fn child_allocation(&self) -> Self
pub fn child_allocation(&self) -> Self
Create a child allocation (for nested invocations)
Trait Implementations§
Source§impl Clone for ResourceAllocation
impl Clone for ResourceAllocation
Source§fn clone(&self) -> ResourceAllocation
fn clone(&self) -> ResourceAllocation
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 ResourceAllocation
impl Debug for ResourceAllocation
Source§impl<'de> Deserialize<'de> for ResourceAllocation
impl<'de> Deserialize<'de> for ResourceAllocation
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 ResourceAllocation
impl RefUnwindSafe for ResourceAllocation
impl Send for ResourceAllocation
impl Sync for ResourceAllocation
impl Unpin for ResourceAllocation
impl UnsafeUnpin for ResourceAllocation
impl UnwindSafe for ResourceAllocation
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