pub struct SystemInfo(/* private fields */);
Expand description
SystemInfo
是一个封装了 sysinfo::System
的结构体,用于获取系统信息。
Implementations§
Source§impl SystemInfo
impl SystemInfo
Sourcepub fn get_cpu_usage(&mut self) -> f32
pub fn get_cpu_usage(&mut self) -> f32
获取全局 CPU 使用率(百分比)。
Sourcepub fn get_cpu_count(&mut self) -> usize
pub fn get_cpu_count(&mut self) -> usize
获取逻辑 CPU 核心数量。
Sourcepub fn get_memory_usage(&mut self) -> u64
pub fn get_memory_usage(&mut self) -> u64
获取已使用的内存大小(单位:字节)。
Sourcepub fn get_memory_available(&mut self) -> u64
pub fn get_memory_available(&mut self) -> u64
获取可用内存大小(单位:字节)。
Sourcepub fn get_total_memory(&mut self) -> u64
pub fn get_total_memory(&mut self) -> u64
获取总内存大小(单位:字节)。
Sourcepub fn get_swap_usage(&mut self) -> u64
pub fn get_swap_usage(&mut self) -> u64
获取已使用的交换空间大小(单位:字节)。
Sourcepub fn get_total_swap(&mut self) -> u64
pub fn get_total_swap(&mut self) -> u64
获取总交换空间大小(单位:字节)。
Sourcepub fn get_process(&mut self) -> &HashMap<Pid, Process>
pub fn get_process(&mut self) -> &HashMap<Pid, Process>
获取当前所有进程的哈希表(PID -> 进程信息)。
Sourcepub fn get_physical_core_count(&mut self) -> Option<usize>
pub fn get_physical_core_count(&mut self) -> Option<usize>
获取物理核心数量(如果支持)。
Sourcepub fn get_process_from_name<'a: 'b, 'b>(
&'a mut self,
name: &'b str,
) -> impl Iterator<Item = &'a Process> + 'b
pub fn get_process_from_name<'a: 'b, 'b>( &'a mut self, name: &'b str, ) -> impl Iterator<Item = &'a Process> + 'b
根据进程名称获取匹配的进程列表。
Sourcepub fn get_process_from_pid(&mut self, pid: u32) -> Option<&Process>
pub fn get_process_from_pid(&mut self, pid: u32) -> Option<&Process>
根据 PID 获取指定的进程信息。
Sourcepub fn get_process_count(&mut self) -> usize
pub fn get_process_count(&mut self) -> usize
获取当前运行的进程数量。
Source§impl SystemInfo
impl SystemInfo
Auto Trait Implementations§
impl Freeze for SystemInfo
impl RefUnwindSafe for SystemInfo
impl Send for SystemInfo
impl Sync for SystemInfo
impl Unpin for SystemInfo
impl UnwindSafe for SystemInfo
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
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, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.
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> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.