pub struct ResourceDescriptor {
pub id: ResourceId,
pub capacity: u64,
pub allocated: u64,
pub label: String,
pub unit: String,
}Expand description
Describes a resource with capacity and current allocation.
Fields§
§id: ResourceIdUnique identifier for this resource.
capacity: u64Maximum capacity available.
allocated: u64Currently allocated amount.
label: StringHuman-readable label.
unit: StringUnit of measurement (e.g., “cores”, “MB”, “Mbps”).
Implementations§
Source§impl ResourceDescriptor
impl ResourceDescriptor
Sourcepub fn new(
id: ResourceId,
capacity: u64,
label: impl Into<String>,
unit: impl Into<String>,
) -> Self
pub fn new( id: ResourceId, capacity: u64, label: impl Into<String>, unit: impl Into<String>, ) -> Self
Create a new resource descriptor.
Sourcepub fn utilisation(&self) -> f64
pub fn utilisation(&self) -> f64
Return the utilisation ratio as a value between 0.0 and 1.0.
Sourcepub fn can_allocate(&self, amount: u64) -> bool
pub fn can_allocate(&self, amount: u64) -> bool
Check whether the requested amount can be satisfied.
Trait Implementations§
Source§impl Clone for ResourceDescriptor
impl Clone for ResourceDescriptor
Source§fn clone(&self) -> ResourceDescriptor
fn clone(&self) -> ResourceDescriptor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ResourceDescriptor
impl RefUnwindSafe for ResourceDescriptor
impl Send for ResourceDescriptor
impl Sync for ResourceDescriptor
impl Unpin for ResourceDescriptor
impl UnsafeUnpin for ResourceDescriptor
impl UnwindSafe for ResourceDescriptor
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