diff --git a/README.md b/README.md index d0de6c39e..815a88b79 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Otherwise, here is a little code sample: ```rust use sysinfo::{ - Components, ComponentsExt, Disks, Networks, System, + Components, Disks, Networks, System, }; // Please note that we use "new_all" to ensure that all list of diff --git a/benches/basic.rs b/benches/basic.rs index 9745fa064..48fa885e1 100644 --- a/benches/basic.rs +++ b/benches/basic.rs @@ -3,7 +3,7 @@ extern crate test; use sysinfo::get_current_pid; -use sysinfo::{ComponentsExt, UsersExt}; +use sysinfo::UsersExt; #[bench] fn bench_new(b: &mut test::Bencher) { diff --git a/examples/simple.rs b/examples/simple.rs index 570d4ba0f..2cedb890e 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -7,9 +7,7 @@ use std::io::{self, BufRead, Write}; use std::str::FromStr; use sysinfo::Signal::*; -use sysinfo::{ - Components, ComponentsExt, Disks, Networks, Pid, Signal, System, UserExt, Users, UsersExt, -}; +use sysinfo::{Components, Disks, Networks, Pid, Signal, System, UserExt, Users, UsersExt}; const signals: &[Signal] = &[ Hangup, diff --git a/md_doc/component.md b/md_doc/component.md deleted file mode 100644 index 618cace2f..000000000 --- a/md_doc/component.md +++ /dev/null @@ -1,16 +0,0 @@ -Struct containing a component information (temperature and name for the moment). - -## Linux - -More information can be found at [kernel.org][k]. - -Note: these may not be present on virtual Linux systems, such as **Docker** -or **Windows Subsystem for Linux**. These hosts do not expose this information -and therefore `Component` elements may be missing or not as expected. - -[k]: https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface - -## Windows - -Please note that on Windows, you need to have Administrator priviledges to get this -information. diff --git a/md_doc/components.md b/md_doc/components.md deleted file mode 100644 index 7ab71b67b..000000000 --- a/md_doc/components.md +++ /dev/null @@ -1,11 +0,0 @@ -Component interfaces. - -```no_run -use sysinfo::{Components, ComponentsExt}; - -let mut components = Components::new(); -components.refresh_list(); -for component in components.components() { - println!("{component:?}"); -} -``` \ No newline at end of file diff --git a/src/common.rs b/src/common.rs index dd94022c7..99c1ed14f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,8 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::{ - ComponentInner, Components, ComponentsExt, CpuInner, NetworkDataInner, NetworksInner, - ProcessInner, SystemInner, User, UserExt, UsersExt, + ComponentInner, ComponentsInner, CpuInner, NetworkDataInner, NetworksInner, ProcessInner, + SystemInner, User, UserExt, UsersExt, }; use std::cmp::Ordering; @@ -2797,10 +2797,142 @@ impl fmt::Display for MacAddr { } } +/// Interacting with components. +/// +/// ```no_run +/// use sysinfo::Components; +/// +/// let mut components = Components::new(); +/// components.refresh_list(); +/// for component in components.iter() { +/// eprintln!("{component:?}"); +/// } +/// ``` +pub struct Components { + pub(crate) inner: ComponentsInner, +} + +impl Default for Components { + fn default() -> Self { + Self::new() + } +} + +impl Components { + /// Creates a new [`Components`][crate::Components] type. + /// + /// ```no_run + /// use sysinfo::Components; + /// + /// let mut components = Components::new(); + /// components.refresh_list(); + /// for component in components.iter() { + /// eprintln!("{component:?}"); + /// } + /// ``` + pub fn new() -> Self { + Self { + inner: ComponentsInner::new(), + } + } + + /// Returns the components list. + /// + /// ```no_run + /// use sysinfo::Components; + /// + /// let mut components = Components::new(); + /// components.refresh_list(); + /// for component in components.components() { + /// eprintln!("{component:?}"); + /// } + /// ``` + pub fn components(&self) -> &[Component] { + self.inner.components() + } + + /// Returns the components list. + /// + /// ```no_run + /// use sysinfo::Components; + /// + /// let mut components = Components::new(); + /// components.refresh_list(); + /// for component in components.components_mut() { + /// component.refresh(); + /// eprintln!("{component:?}"); + /// } + /// ``` + pub fn components_mut(&mut self) -> &mut [Component] { + self.inner.components_mut() + } + + /// Sort the components list with the provided callback. + /// + /// Internally, it is using the [`slice::sort_unstable_by`] function, so please refer to it + /// for implementation details. + /// + /// You can do the same without this method by calling: + /// + /// ```no_run + /// use sysinfo::Components; + /// + /// let mut components = Components::new(); + /// components.refresh_list(); + /// components.sort_by(|component1, component2| { + /// component2.label().partial_cmp(component2.label()).unwrap() + /// }); + /// ``` + /// + /// ⚠️ If you use [`Components::refresh_list`], you will need to call this method to sort the + /// components again. + pub fn sort_by(&mut self, compare: F) + where + F: FnMut(&Component, &Component) -> std::cmp::Ordering, + { + self.components_mut().sort_unstable_by(compare); + } + + /// Refreshes the listed components' information. + /// + /// ⚠️ If a component is added or removed, this method won't take it into account. Use + /// [`Components::refresh_list`] instead. + /// + /// ⚠️ If you didn't call [`Components::refresh_list`] beforehand, this method will do + /// nothing as the component list will be empty. + /// + /// ```no_run + /// use sysinfo::Components; + /// + /// let mut components = Components::new(); + /// // We get the component list. + /// components.refresh_list(); + /// // We wait some time...? + /// components.refresh(); + /// ``` + pub fn refresh(&mut self) { + for component in self.components_mut() { + component.refresh(); + } + } + + /// The component list will be emptied then completely recomputed. + /// + /// ```no_run + /// use sysinfo::Components; + /// + /// let mut components = Components::new(); + /// components.refresh_list(); + /// ``` + pub fn refresh_list(&mut self) { + self.inner.refresh_list() + } +} + /// Getting a component temperature information. /// /// ```no_run -/// use sysinfo::{Components, ComponentsExt}; +/// use sysinfo::Components; /// /// let mut components = Components::new(); /// components.refresh_list(); @@ -2820,7 +2952,7 @@ impl Component { /// Returns `f32::NAN` if it failed to retrieve it. /// /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; + /// use sysinfo::Components; /// /// let mut components = Components::new(); /// components.refresh_list(); @@ -2838,7 +2970,7 @@ impl Component { /// `max` value will be updated on refresh. /// /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; + /// use sysinfo::Components; /// /// let mut components = Components::new(); /// components.refresh_list(); @@ -2858,7 +2990,7 @@ impl Component { /// Returns the highest temperature before the component halts (in celsius degree). /// /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; + /// use sysinfo::Components; /// /// let mut components = Components::new(); /// components.refresh_list(); @@ -2877,7 +3009,7 @@ impl Component { /// Returns the label of the component. /// /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; + /// use sysinfo::Components; /// /// let mut components = Components::new(); /// components.refresh_list(); @@ -2905,7 +3037,7 @@ impl Component { /// Refreshes component. /// /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; + /// use sysinfo::Components; /// /// let mut components = Components::new(); /// components.refresh_list(); diff --git a/src/lib.rs b/src/lib.rs index edc208608..d86ca288f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,19 +52,17 @@ cfg_if::cfg_if! { } pub use crate::common::{ - get_current_pid, Component, Cpu, CpuRefreshKind, Disk, DiskKind, DiskUsage, Disks, Gid, Group, - LoadAvg, MacAddr, NetworkData, Networks, NetworksIter, Pid, PidExt, Process, + get_current_pid, Component, Components, Cpu, CpuRefreshKind, Disk, DiskKind, DiskUsage, Disks, + Gid, Group, LoadAvg, MacAddr, NetworkData, Networks, NetworksIter, Pid, PidExt, Process, ProcessRefreshKind, ProcessStatus, RefreshKind, Signal, System, Uid, Users, }; pub(crate) use crate::sys::{ - ComponentInner, CpuInner, DiskInner, DisksInner, NetworkDataInner, NetworksInner, ProcessInner, - SystemInner, + ComponentInner, ComponentsInner, CpuInner, DiskInner, DisksInner, NetworkDataInner, + NetworksInner, ProcessInner, SystemInner, }; -pub use crate::sys::{ - Components, User, IS_SUPPORTED, MINIMUM_CPU_UPDATE_INTERVAL, SUPPORTED_SIGNALS, -}; -pub use crate::traits::{ComponentsExt, UserExt, UsersExt}; +pub use crate::sys::{User, IS_SUPPORTED, MINIMUM_CPU_UPDATE_INTERVAL, SUPPORTED_SIGNALS}; +pub use crate::traits::{UserExt, UsersExt}; #[cfg(feature = "c-interface")] pub use crate::c_interface::*; diff --git a/src/traits.rs b/src/traits.rs index 2d746a97f..f8eea8e2a 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1,122 +1,10 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::common::{Gid, Uid}; -use crate::{Component, Group, User}; +use crate::{Group, User}; use std::fmt::Debug; -/// Interacting with components. -/// -/// ```no_run -/// use sysinfo::{Components, ComponentsExt}; -/// -/// let mut components = Components::new(); -/// components.refresh_list(); -/// for component in components.iter() { -/// eprintln!("{component:?}"); -/// } -/// ``` -pub trait ComponentsExt: Debug { - /// Creates a new [`Components`][crate::Components] type. - /// - /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; - /// - /// let mut components = Components::new(); - /// components.refresh_list(); - /// for component in components.iter() { - /// eprintln!("{component:?}"); - /// } - /// ``` - fn new() -> Self; - - /// Returns the components list. - /// - /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; - /// - /// let mut components = Components::new(); - /// components.refresh_list(); - /// for component in components.components() { - /// eprintln!("{component:?}"); - /// } - /// ``` - fn components(&self) -> &[Component]; - - /// Returns the components list. - /// - /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; - /// - /// let mut components = Components::new(); - /// components.refresh_list(); - /// for component in components.components_mut() { - /// component.refresh(); - /// eprintln!("{component:?}"); - /// } - /// ``` - fn components_mut(&mut self) -> &mut [Component]; - - /// Sort the components list with the provided callback. - /// - /// Internally, it is using the [`slice::sort_unstable_by`] function, so please refer to it - /// for implementation details. - /// - /// You can do the same without this method by calling: - /// - /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; - /// - /// let mut components = Components::new(); - /// components.refresh_list(); - /// components.sort_by(|component1, component2| { - /// component2.label().partial_cmp(component2.label()).unwrap() - /// }); - /// ``` - /// - /// ⚠️ If you use [`ComponentsExt::refresh_list`], you will need to call this method to sort the - /// components again. - fn sort_by(&mut self, compare: F) - where - F: FnMut(&Component, &Component) -> std::cmp::Ordering, - { - self.components_mut().sort_unstable_by(compare); - } - - /// Refreshes the listed components' information. - /// - /// ⚠️ If a component is added or removed, this method won't take it into account. Use - /// [`ComponentsExt::refresh_list`] instead. - /// - /// ⚠️ If you didn't call [`ComponentsExt::refresh_list`] beforehand, this method will do - /// nothing as the component list will be empty. - /// - /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; - /// - /// let mut components = Components::new(); - /// // We get the component list. - /// components.refresh_list(); - /// // We wait some time...? - /// components.refresh(); - /// ``` - fn refresh(&mut self) { - for component in self.components_mut() { - component.refresh(); - } - } - - /// The component list will be emptied then completely recomputed. - /// - /// ```no_run - /// use sysinfo::{Components, ComponentsExt}; - /// - /// let mut components = Components::new(); - /// components.refresh_list(); - /// ``` - fn refresh_list(&mut self); -} - /// Getting information for a user. /// /// It is returned from [`UsersExt::users`]. diff --git a/src/unix/apple/app_store/component.rs b/src/unix/apple/app_store/component.rs index effe44646..5be927629 100644 --- a/src/unix/apple/app_store/component.rs +++ b/src/unix/apple/app_store/component.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{Component, ComponentsExt}; +use crate::Component; pub(crate) struct ComponentInner; @@ -24,27 +24,26 @@ impl ComponentInner { pub(crate) fn refresh(&mut self) {} } -#[doc = include_str!("../../../../md_doc/components.md")] -pub struct Components { +pub(crate) struct ComponentsInner { components: Vec, } -impl ComponentsExt for Components { - fn new() -> Self { +impl ComponentsInner { + pub(crate) fn new() -> Self { Self { components: Vec::new(), } } - fn components(&self) -> &[Component] { + pub(crate) fn components(&self) -> &[Component] { &self.components } - fn components_mut(&mut self) -> &mut [Component] { + pub(crate) fn components_mut(&mut self) -> &mut [Component] { &mut self.components } - fn refresh_list(&mut self) { + pub(crate) fn refresh_list(&mut self) { // Doesn't do anything. } } diff --git a/src/unix/apple/component.rs b/src/unix/apple/component.rs index 7c4196e72..7ebf0b9d8 100644 --- a/src/unix/apple/component.rs +++ b/src/unix/apple/component.rs @@ -1,3 +1,3 @@ // Take a look at the license at the top of the repository in the LICENSE file. -pub use crate::sys::inner::component::*; +pub(crate) use crate::sys::inner::component::*; diff --git a/src/unix/apple/macos/component/arm.rs b/src/unix/apple/macos/component/arm.rs index e3e0de130..e6634b446 100644 --- a/src/unix/apple/macos/component/arm.rs +++ b/src/unix/apple/macos/component/arm.rs @@ -16,31 +16,30 @@ use crate::sys::inner::ffi::{ HID_DEVICE_PROPERTY_PRODUCT, }; use crate::sys::utils::CFReleaser; -use crate::{Component, ComponentsExt}; +use crate::Component; -#[doc = include_str!("../../../../../md_doc/components.md")] -pub struct Components { +pub(crate) struct ComponentsInner { components: Vec, client: Option>, } -impl ComponentsExt for Components { - fn new() -> Self { +impl ComponentsInner { + pub(crate) fn new() -> Self { Self { components: vec![], client: None, } } - fn components(&self) -> &[Component] { + pub(crate) fn components(&self) -> &[Component] { &self.components } - fn components_mut(&mut self) -> &mut [Component] { + pub(crate) fn components_mut(&mut self) -> &mut [Component] { &mut self.components } - fn refresh_list(&mut self) { + pub(crate) fn refresh_list(&mut self) { self.components.clear(); unsafe { diff --git a/src/unix/apple/macos/component/mod.rs b/src/unix/apple/macos/component/mod.rs index 50b359e61..7907cf79b 100644 --- a/src/unix/apple/macos/component/mod.rs +++ b/src/unix/apple/macos/component/mod.rs @@ -4,10 +4,10 @@ pub(crate) mod x86; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -pub use self::x86::*; +pub(crate) use self::x86::*; #[cfg(target_arch = "aarch64")] pub(crate) mod arm; #[cfg(target_arch = "aarch64")] -pub use self::arm::*; +pub(crate) use self::arm::*; diff --git a/src/unix/apple/macos/component/x86.rs b/src/unix/apple/macos/component/x86.rs index 282c875a5..a6dd97d63 100644 --- a/src/unix/apple/macos/component/x86.rs +++ b/src/unix/apple/macos/component/x86.rs @@ -1,7 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::sys::{ffi, macos::utils::IOReleaser}; -use crate::{Component, ComponentsExt}; +use crate::Component; use libc::{c_char, c_int, c_void}; @@ -45,29 +45,28 @@ impl ComponentFFI { } // Used to get CPU information, not supported on iOS, or inside the default macOS sandbox. -#[doc = include_str!("../../../../../md_doc/components.md")] -pub struct Components { +pub(crate) struct ComponentsInner { components: Vec, connection: Option, } -impl ComponentsExt for Components { - fn new() -> Self { +impl ComponentsInner { + pub(crate) fn new() -> Self { Self { components: Vec::with_capacity(2), connection: IoService::new_connection(), } } - fn components(&self) -> &[Component] { + pub(crate) fn components(&self) -> &[Component] { &self.components } - fn components_mut(&mut self) -> &mut [Component] { + pub(crate) fn components_mut(&mut self) -> &mut [Component] { &mut self.components } - fn refresh_list(&mut self) { + pub(crate) fn refresh_list(&mut self) { if let Some(ref connection) = self.connection { let connection = connection.inner(); self.components.clear(); diff --git a/src/unix/apple/mod.rs b/src/unix/apple/mod.rs index 3556298df..d2a9f8cd5 100644 --- a/src/unix/apple/mod.rs +++ b/src/unix/apple/mod.rs @@ -24,8 +24,7 @@ pub mod system; pub mod users; mod utils; -pub(crate) use self::component::ComponentInner; -pub use self::component::Components; +pub(crate) use self::component::{ComponentInner, ComponentsInner}; pub(crate) use self::cpu::CpuInner; pub(crate) use self::disk::DiskInner; pub(crate) use self::network::{NetworkDataInner, NetworksInner}; diff --git a/src/unix/freebsd/component.rs b/src/unix/freebsd/component.rs index 21fe47a0f..fb4722c67 100644 --- a/src/unix/freebsd/component.rs +++ b/src/unix/freebsd/component.rs @@ -1,7 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. use super::utils::get_sys_value_by_name; -use crate::{Component, ComponentsExt}; +use crate::Component; pub(crate) struct ComponentInner { id: Vec, @@ -49,14 +49,13 @@ unsafe fn refresh_component(id: &[u8]) -> Option { } } -#[doc = include_str!("../../../md_doc/components.md")] -pub struct Components { +pub(crate) struct ComponentsInner { nb_cpus: usize, components: Vec, } -impl ComponentsExt for Components { - fn new() -> Self { +impl ComponentsInner { + pub(crate) fn new() -> Self { let nb_cpus = unsafe { super::cpu::get_nb_cpus() }; Self { nb_cpus, @@ -64,15 +63,15 @@ impl ComponentsExt for Components { } } - fn components(&self) -> &[Component] { + pub(crate) fn components(&self) -> &[Component] { &self.components } - fn components_mut(&mut self) -> &mut [Component] { + pub(crate) fn components_mut(&mut self) -> &mut [Component] { &mut self.components } - fn refresh_list(&mut self) { + pub(crate) fn refresh_list(&mut self) { self.components.clear(); for core in 0..self.nb_cpus { unsafe { diff --git a/src/unix/freebsd/mod.rs b/src/unix/freebsd/mod.rs index 9cb632e7d..cef20ef04 100644 --- a/src/unix/freebsd/mod.rs +++ b/src/unix/freebsd/mod.rs @@ -8,8 +8,7 @@ pub mod process; pub mod system; mod utils; -pub(crate) use self::component::ComponentInner; -pub use self::component::Components; +pub(crate) use self::component::{ComponentInner, ComponentsInner}; pub(crate) use self::cpu::CpuInner; pub(crate) use self::disk::DiskInner; pub(crate) use self::network::{NetworkDataInner, NetworksInner}; diff --git a/src/unix/linux/component.rs b/src/unix/linux/component.rs index 5efc68ce0..91dca27a0 100644 --- a/src/unix/linux/component.rs +++ b/src/unix/linux/component.rs @@ -4,7 +4,7 @@ // // Values in /sys/class/hwmonN are `c_long` or `c_ulong` // transposed to rust we only read `u32` or `i32` values. -use crate::{Component, ComponentsExt}; +use crate::Component; use std::collections::HashMap; use std::fs::{read_dir, File}; @@ -331,27 +331,26 @@ impl ComponentInner { } } -#[doc = include_str!("../../../md_doc/components.md")] -pub struct Components { +pub(crate) struct ComponentsInner { components: Vec, } -impl ComponentsExt for Components { - fn new() -> Self { +impl ComponentsInner { + pub(crate) fn new() -> Self { Self { components: Vec::with_capacity(4), } } - fn components(&self) -> &[Component] { + pub(crate) fn components(&self) -> &[Component] { &self.components } - fn components_mut(&mut self) -> &mut [Component] { + pub(crate) fn components_mut(&mut self) -> &mut [Component] { &mut self.components } - fn refresh_list(&mut self) { + pub(crate) fn refresh_list(&mut self) { self.components.clear(); if let Ok(dir) = read_dir(Path::new("/sys/class/hwmon/")) { for entry in dir.flatten() { diff --git a/src/unix/linux/mod.rs b/src/unix/linux/mod.rs index 63605dd9f..1750b6580 100644 --- a/src/unix/linux/mod.rs +++ b/src/unix/linux/mod.rs @@ -8,8 +8,7 @@ pub mod process; pub mod system; pub(crate) mod utils; -pub(crate) use self::component::ComponentInner; -pub use self::component::Components; +pub(crate) use self::component::{ComponentInner, ComponentsInner}; pub(crate) use self::cpu::CpuInner; pub(crate) use self::disk::DiskInner; pub(crate) use self::network::{NetworkDataInner, NetworksInner}; diff --git a/src/unknown/component.rs b/src/unknown/component.rs index 04aa940b4..5be927629 100644 --- a/src/unknown/component.rs +++ b/src/unknown/component.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{Component, ComponentsExt}; +use crate::Component; pub(crate) struct ComponentInner; @@ -24,27 +24,26 @@ impl ComponentInner { pub(crate) fn refresh(&mut self) {} } -#[doc = include_str!("../../md_doc/components.md")] -pub struct Components { +pub(crate) struct ComponentsInner { components: Vec, } -impl ComponentsExt for Components { - fn new() -> Self { +impl ComponentsInner { + pub(crate) fn new() -> Self { Self { components: Vec::new(), } } - fn components(&self) -> &[Component] { + pub(crate) fn components(&self) -> &[Component] { &self.components } - fn components_mut(&mut self) -> &mut [Component] { + pub(crate) fn components_mut(&mut self) -> &mut [Component] { &mut self.components } - fn refresh_list(&mut self) { + pub(crate) fn refresh_list(&mut self) { // Doesn't do anything. } } diff --git a/src/unknown/mod.rs b/src/unknown/mod.rs index 7666134ad..06b15e3a3 100644 --- a/src/unknown/mod.rs +++ b/src/unknown/mod.rs @@ -8,8 +8,7 @@ pub mod process; pub mod system; pub mod users; -pub(crate) use self::component::ComponentInner; -pub use self::component::Components; +pub(crate) use self::component::{ComponentInner, ComponentsInner}; pub(crate) use self::cpu::CpuInner; pub(crate) use self::disk::{DiskInner, DisksInner}; pub(crate) use self::network::{NetworkDataInner, NetworksInner}; diff --git a/src/windows/component.rs b/src/windows/component.rs index b0223cea3..aa3297313 100644 --- a/src/windows/component.rs +++ b/src/windows/component.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{Component, ComponentsExt}; +use crate::Component; use windows::core::w; use windows::Win32::Foundation::{SysAllocString, SysFreeString}; @@ -85,27 +85,26 @@ impl ComponentInner { } } -#[doc = include_str!("../../md_doc/components.md")] -pub struct Components { +pub(crate) struct ComponentsInner { components: Vec, } -impl ComponentsExt for Components { - fn new() -> Self { +impl ComponentsInner { + pub(crate) fn new() -> Self { Self { components: Vec::new(), } } - fn components(&self) -> &[Component] { + pub(crate) fn components(&self) -> &[Component] { &self.components } - fn components_mut(&mut self) -> &mut [Component] { + pub(crate) fn components_mut(&mut self) -> &mut [Component] { &mut self.components } - fn refresh_list(&mut self) { + pub(crate) fn refresh_list(&mut self) { self.components = match ComponentInner::new() { Some(c) => vec![Component { inner: c }], None => Vec::new(), diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 20d13950b..951ec01e2 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -12,8 +12,7 @@ mod tools; mod users; mod utils; -pub(crate) use self::component::ComponentInner; -pub use self::component::Components; +pub(crate) use self::component::{ComponentInner, ComponentsInner}; pub(crate) use self::cpu::CpuInner; pub(crate) use self::disk::{DiskInner, DisksInner}; pub(crate) use self::network::{NetworkDataInner, NetworksInner};