pub struct Resource {
pub id: String,
pub name: String,
pub resource_type: ResourceType,
pub capacity: i32,
pub efficiency: f64,
pub calendar: Option<Calendar>,
pub skills: Vec<Skill>,
pub cost_per_hour: Option<f64>,
pub attributes: HashMap<String, String>,
}Expand description
A resource that can be assigned to activities.
Fields§
§id: StringUnique resource identifier.
name: StringHuman-readable name.
resource_type: ResourceTypeResource classification.
capacity: i32Number of units available simultaneously (default: 1).
efficiency: f64Work rate multiplier (1.0 = normal, <1.0 = slower, >1.0 = faster).
calendar: Option<Calendar>Availability schedule.
skills: Vec<Skill>Skills with proficiency levels.
cost_per_hour: Option<f64>Economic cost per hour (optional, for cost optimization).
attributes: HashMap<String, String>Domain-specific metadata.
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn new(id: impl Into<String>, resource_type: ResourceType) -> Self
pub fn new(id: impl Into<String>, resource_type: ResourceType) -> Self
Creates a new primary resource.
Sourcepub fn with_capacity(self, capacity: i32) -> Self
pub fn with_capacity(self, capacity: i32) -> Self
Sets the capacity.
Sourcepub fn with_efficiency(self, efficiency: f64) -> Self
pub fn with_efficiency(self, efficiency: f64) -> Self
Sets the efficiency multiplier.
Sourcepub fn with_calendar(self, calendar: Calendar) -> Self
pub fn with_calendar(self, calendar: Calendar) -> Self
Sets the availability calendar.
Sourcepub fn with_skill(self, name: impl Into<String>, level: f64) -> Self
pub fn with_skill(self, name: impl Into<String>, level: f64) -> Self
Adds a skill.
Sourcepub fn with_attribute(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_attribute( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a domain-specific attribute.
Sourcepub fn skill_level(&self, name: &str) -> f64
pub fn skill_level(&self, name: &str) -> f64
Returns the proficiency level for a skill (0.0 if not found).
Sourcepub fn is_available_at(&self, time_ms: i64) -> bool
pub fn is_available_at(&self, time_ms: i64) -> bool
Checks availability at a given time (ms).
Returns true if no calendar is set (always available)
or if the calendar indicates working time.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Resource
impl<'de> Deserialize<'de> for Resource
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 Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnsafeUnpin for Resource
impl UnwindSafe for Resource
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