pub struct SystemResources {
pub cpu_cores: usize,
pub cpu_threads: usize,
pub total_memory_mb: u64,
pub available_memory_mb: u64,
}Expand description
系统资源信息
Fields§
§cpu_cores: usizeCPU物理核心数
cpu_threads: usizeCPU逻辑线程数
total_memory_mb: u64系统总内存(MB)
available_memory_mb: u64系统可用内存(MB)
Implementations§
Source§impl SystemResources
impl SystemResources
Sourcepub fn resource_tier(&self) -> ResourceTier
pub fn resource_tier(&self) -> ResourceTier
判断系统资源等级
根据CPU核心数和内存大小评估系统资源等级:
- High: 8核以上 + 16GB以上内存
- Medium: 4核以上 + 8GB以上内存
- Low: 其他配置
§返回值
ResourceTier- 系统资源等级枚举
§示例
let resources = SystemResources::detect();
match resources.resource_tier() {
ResourceTier::High => println!("高配系统"),
ResourceTier::Medium => println!("中配系统"),
ResourceTier::Low => println!("低配系统"),
}Sourcepub fn tier_description(&self) -> &'static str
pub fn tier_description(&self) -> &'static str
获取系统资源等级的描述字符串
Trait Implementations§
Source§impl Clone for SystemResources
impl Clone for SystemResources
Source§fn clone(&self) -> SystemResources
fn clone(&self) -> SystemResources
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 moreAuto Trait Implementations§
impl Freeze for SystemResources
impl RefUnwindSafe for SystemResources
impl Send for SystemResources
impl Sync for SystemResources
impl Unpin for SystemResources
impl UnwindSafe for SystemResources
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 moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage