pub struct ResourcePool {
pub resources: HashMap<ResourceType, ResourceAmount>,
pub utilization: HashMap<ResourceType, f64>,
pub last_updated: DateTime<Utc>,
}Expand description
Resource pool for tracking available resources
Fields§
§resources: HashMap<ResourceType, ResourceAmount>Available resources by type
utilization: HashMap<ResourceType, f64>Resource utilization tracking
last_updated: DateTime<Utc>Last updated timestamp
Implementations§
Source§impl ResourcePool
impl ResourcePool
Sourcepub fn set_resource(
&mut self,
resource_type: ResourceType,
amount: ResourceAmount,
)
pub fn set_resource( &mut self, resource_type: ResourceType, amount: ResourceAmount, )
Add or update a resource
Sourcepub fn add_resource(
&mut self,
resource_type: ResourceType,
amount: ResourceAmount,
)
pub fn add_resource( &mut self, resource_type: ResourceType, amount: ResourceAmount, )
Add a resource (alias for set_resource)
Sourcepub fn get_resource(
&self,
resource_type: &ResourceType,
) -> Option<&ResourceAmount>
pub fn get_resource( &self, resource_type: &ResourceType, ) -> Option<&ResourceAmount>
Get available amount for a resource type
Sourcepub fn set_utilization(&mut self, resource_type: ResourceType, utilization: f64)
pub fn set_utilization(&mut self, resource_type: ResourceType, utilization: f64)
Set resource utilization
Sourcepub fn get_utilization(&self, resource_type: &ResourceType) -> f64
pub fn get_utilization(&self, resource_type: &ResourceType) -> f64
Get resource utilization
Sourcepub fn has_resource(&self, resource_type: &ResourceType) -> bool
pub fn has_resource(&self, resource_type: &ResourceType) -> bool
Check if a resource type is available
Sourcepub fn calculate_utilization(
&self,
resource_type: &ResourceType,
used: &ResourceAmount,
) -> f64
pub fn calculate_utilization( &self, resource_type: &ResourceType, used: &ResourceAmount, ) -> f64
Calculate utilization for a specific resource
Sourcepub fn is_available(
&self,
resource_type: &ResourceType,
required: &ResourceAmount,
) -> bool
pub fn is_available( &self, resource_type: &ResourceType, required: &ResourceAmount, ) -> bool
Check if a specific amount is available
Sourcepub fn can_satisfy(
&self,
requirements: &[ResourceRequirement],
) -> Vec<ResourceGap>
pub fn can_satisfy( &self, requirements: &[ResourceRequirement], ) -> Vec<ResourceGap>
Check if requirements can be satisfied
Sourcepub fn satisfaction_score(&self, requirements: &[ResourceRequirement]) -> f64
pub fn satisfaction_score(&self, requirements: &[ResourceRequirement]) -> f64
Calculate overall satisfaction score (0-10)
Trait Implementations§
Source§impl Clone for ResourcePool
impl Clone for ResourcePool
Source§fn clone(&self) -> ResourcePool
fn clone(&self) -> ResourcePool
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 ResourcePool
impl Debug for ResourcePool
Source§impl Default for ResourcePool
impl Default for ResourcePool
Source§impl<'de> Deserialize<'de> for ResourcePool
impl<'de> Deserialize<'de> for ResourcePool
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 ResourcePool
impl RefUnwindSafe for ResourcePool
impl Send for ResourcePool
impl Sync for ResourcePool
impl Unpin for ResourcePool
impl UnwindSafe for ResourcePool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more