Repository: GuillaumeGomez/sysinfo
Pull request #1090 (2023-10-07 13:25:25)

Remove DisksExt trait
Part of #1088.


Patch:
diff --git a/README.md b/README.md
index 44b5452..74f17c4 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ Otherwise, here is a little code sample:
 
 ```rust
 use sysinfo::{
-    Components, ComponentsExt, Disks, DisksExt, NetworkExt, Networks,
+    Components, ComponentsExt, Disks, NetworkExt, Networks,
     NetworksExt, ProcessExt, System, SystemExt,
 };
 
diff --git a/benches/basic.rs b/benches/basic.rs
index 9439be1..d1b4ba4 100644
--- a/benches/basic.rs
+++ b/benches/basic.rs
@@ -3,7 +3,7 @@
 extern crate test;
 
 use sysinfo::get_current_pid;
-use sysinfo::{ComponentsExt, DiskExt, DisksExt, NetworksExt, SystemExt, UsersExt};
+use sysinfo::{ComponentsExt, DiskExt, NetworksExt, SystemExt, UsersExt};
 
 #[bench]
 fn bench_new(b: &mut test::Bencher) {
diff --git a/examples/simple.rs b/examples/simple.rs
index 785d4c6..eb64cee 100644
--- a/examples/simple.rs
+++ b/examples/simple.rs
@@ -8,8 +8,8 @@ use std::io::{self, BufRead, Write};
 use std::str::FromStr;
 use sysinfo::Signal::*;
 use sysinfo::{
-    Components, ComponentsExt, CpuExt, Disks, DisksExt, NetworkExt, Networks, NetworksExt, Pid,
-    ProcessExt, Signal, System, SystemExt, UserExt, Users, UsersExt,
+    Components, ComponentsExt, CpuExt, Disks, NetworkExt, Networks, NetworksExt, Pid, ProcessExt,
+    Signal, System, SystemExt, UserExt, Users, UsersExt,
 };
 
 const signals: &[Signal] = &[
diff --git a/src/c_interface.rs b/src/c_interface.rs
index 5cab028..b7cbff3 100644
--- a/src/c_interface.rs
+++ b/src/c_interface.rs
@@ -1,8 +1,7 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
 use crate::{
-    CpuExt, Disks, DisksExt, NetworkExt, Networks, NetworksExt, Pid, Process, ProcessExt, System,
-    SystemExt,
+    CpuExt, Disks, NetworkExt, Networks, NetworksExt, Pid, Process, ProcessExt, System, SystemExt,
 };
 use libc::{self, c_char, c_float, c_uint, c_void, size_t};
 use std::borrow::BorrowMut;
diff --git a/src/common.rs b/src/common.rs
index a41c43f..a3a68b1 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::{
-    Component, Components, ComponentsExt, Disk, GroupExt, NetworkData, NetworksExt, User, UserExt,
-    UsersExt,
+    Component, Components, ComponentsExt, Disk, DiskExt, GroupExt, NetworkData, NetworksExt, User,
+    UserExt, UsersExt,
 };
 
 use std::cmp::Ordering;
@@ -473,10 +473,10 @@ impl<'a> Iterator for NetworksIter<'a> {
     }
 }
 
-/// Disk interfaces.
+/// Disks interface.
 ///
 /// ```no_run
-/// use sysinfo::{Disks, DisksExt};
+/// use sysinfo::Disks;
 ///
 /// let mut disks = Disks::new();
 /// disks.refresh_list();
@@ -485,20 +485,147 @@ impl<'a> Iterator for NetworksIter<'a> {
 /// }
 /// ```
 pub struct Disks {
-    pub(crate) disks: Vec<Disk>,
+    pub(crate) inner: crate::DisksInner,
+}
+
+impl Default for Disks {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl Disks {
+    /// Creates a new [`Disks`][crate::Disks] type.
+    ///
+    /// ```no_run
+    /// use sysinfo::Disks;
+    ///
+    /// let mut disks = Disks::new();
+    /// disks.refresh_list();
+    /// for disk in disks.disks() {
+    ///     eprintln!("{disk:?}");
+    /// }
+    /// ```
+    pub fn new() -> Self {
+        Self {
+            inner: crate::DisksInner::new(),
+        }
+    }
+
+    /// Returns the disks list.
+    ///
+    /// ```no_run
+    /// use sysinfo::Disks;
+    ///
+    /// let mut disks = Disks::new();
+    /// disks.refresh_list();
+    /// for disk in disks.disks() {
+    ///     eprintln!("{disk:?}");
+    /// }
+    /// ```
+    pub fn disks(&self) -> &[Disk] {
+        self.inner.disks()
+    }
+
+    /// Returns the disks list.
+    ///
+    /// ```no_run
+    /// use sysinfo::{DiskExt, Disks};
+    ///
+    /// let mut disks = Disks::new();
+    /// disks.refresh_list();
+    /// for disk in disks.disks_mut() {
+    ///     disk.refresh();
+    ///     eprintln!("{disk:?}");
+    /// }
+    /// ```
+    pub fn disks_mut(&mut self) -> &mut [Disk] {
+        self.inner.disks_mut()
+    }
+
+    /// Sort the disk 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::{DiskExt, Disks};
+    ///
+    /// let mut disks = Disks::new();
+    /// disks.refresh_list();
+    /// disks.sort_by(|disk1, disk2| {
+    ///     disk1.name().partial_cmp(disk2.name()).unwrap()
+    /// });
+    /// ```
+    ///
+    /// ⚠️ If you use [`Disks::refresh_list`], you will need to call this method to sort the
+    /// disks again.
+    pub fn sort_by<F>(&mut self, compare: F)
+    where
+        F: FnMut(&Disk, &Disk) -> std::cmp::Ordering,
+    {
+        self.disks_mut().sort_unstable_by(compare);
+    }
+
+    /// Refreshes the listed disks' information.
+    ///
+    /// ⚠️ If a disk is added or removed, this method won't take it into account. Use
+    /// [`Disks::refresh_list`] instead.
+    ///
+    /// ⚠️ If you didn't call [`Disks::refresh_list`] beforehand, this method will do nothing as
+    /// the disk list will be empty.
+    ///
+    /// ```no_run
+    /// use sysinfo::Disks;
+    ///
+    /// let mut disks = Disks::new();
+    /// // We get the disk list.
+    /// disks.refresh_list();
+    /// // We wait some time...?
+    /// disks.refresh();
+    /// ```
+    pub fn refresh(&mut self) {
+        for disk in self.disks_mut() {
+            disk.refresh();
+        }
+    }
+
+    /// The disk list will be emptied then completely recomputed.
+    ///
+    /// ## Linux
+    ///
+    /// ⚠️ On Linux, the [NFS](https://en.wikipedia.org/wiki/Network_File_System) file
+    /// systems are ignored and the information of a mounted NFS **cannot** be obtained
+    /// via [`Disks::refresh_list`]. This is due to the fact that I/O function
+    /// `statvfs` used by [`Disks::refresh_list`] is blocking and
+    /// [may hang](https://github.com/GuillaumeGomez/sysinfo/pull/876) in some cases,
+    /// requiring to call `systemctl stop` to terminate the NFS service from the remote
+    /// server in some cases.
+    ///
+    /// ```no_run
+    /// use sysinfo::Disks;
+    ///
+    /// let mut disks = Disks::new();
+    /// disks.refresh_list();
+    /// ```
+    pub fn refresh_list(&mut self) {
+        self.inner.refresh_list();
+    }
 }
 
 impl std::ops::Deref for Disks {
     type Target = [Disk];
 
     fn deref(&self) -> &Self::Target {
-        &self.disks
+        self.disks()
     }
 }
 
 impl std::ops::DerefMut for Disks {
     fn deref_mut(&mut self) -> &mut Self::Target {
-        &mut self.disks
+        self.disks_mut()
     }
 }
 
@@ -507,7 +634,7 @@ impl std::ops::DerefMut for Disks {
 /// This type is returned by [`DiskExt::kind`](`crate::DiskExt::kind`).
 ///
 /// ```no_run
-/// use sysinfo::{DiskExt, Disks, DisksExt};
+/// use sysinfo::{DiskExt, Disks};
 ///
 /// let mut disks = Disks::new();
 /// disks.refresh_list();
diff --git a/src/lib.rs b/src/lib.rs
index 9a23335..2e8f0a0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -56,10 +56,11 @@ pub use crate::common::{
     Networks, NetworksIter, Pid, PidExt, ProcessRefreshKind, ProcessStatus, RefreshKind, Signal,
     Uid, Users,
 };
+pub(crate) use crate::sys::DisksInner;
 pub use crate::sys::{Component, Components, Cpu, Disk, NetworkData, Process, System, User};
 pub use crate::traits::{
-    ComponentExt, ComponentsExt, CpuExt, DiskExt, DisksExt, GroupExt, NetworkExt, NetworksExt,
-    ProcessExt, SystemExt, UserExt, UsersExt,
+    ComponentExt, ComponentsExt, CpuExt, DiskExt, GroupExt, NetworkExt, NetworksExt, ProcessExt,
+    SystemExt, UserExt, UsersExt,
 };
 
 #[cfg(feature = "c-interface")]
diff --git a/src/traits.rs b/src/traits.rs
index 467610f..1218b8e 100644
--- a/src/traits.rs
+++ b/src/traits.rs
@@ -2,7 +2,7 @@
 
 use crate::{
     common::{Gid, MacAddr, Uid},
-    sys::{Component, Cpu, Disk, Process},
+    sys::{Component, Cpu, Process},
 };
 use crate::{
     CpuRefreshKind, DiskKind, DiskUsage, Group, LoadAvg, NetworksIter, Pid, ProcessRefreshKind,
@@ -18,7 +18,7 @@ use std::time::Duration;
 /// Contains all the methods of the [`Disk`][crate::Disk] struct.
 ///
 /// ```no_run
-/// use sysinfo::{DiskExt, Disks, DisksExt};
+/// use sysinfo::{DiskExt, Disks};
 ///
 /// let mut disks = Disks::new();
 /// disks.refresh_list();
@@ -30,7 +30,7 @@ pub trait DiskExt: Debug {
     /// Returns the kind of disk.
     ///
     /// ```no_run
-    /// use sysinfo::{DiskExt, Disks, DisksExt};
+    /// use sysinfo::{DiskExt, Disks};
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
@@ -43,7 +43,7 @@ pub trait DiskExt: Debug {
     /// Returns the disk name.
     ///
     /// ```no_run
-    /// use sysinfo::{DiskExt, Disks, DisksExt};
+    /// use sysinfo::{DiskExt, Disks};
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
@@ -56,7 +56,7 @@ pub trait DiskExt: Debug {
     /// Returns the file system used on this disk (so for example: `EXT4`, `NTFS`, etc...).
     ///
     /// ```no_run
-    /// use sysinfo::{DiskExt, Disks, DisksExt};
+    /// use sysinfo::{DiskExt, Disks};
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
@@ -69,7 +69,7 @@ pub trait DiskExt: Debug {
     /// Returns the mount point of the disk (`/` for example).
     ///
     /// ```no_run
-    /// use sysinfo::{DiskExt, Disks, DisksExt};
+    /// use sysinfo::{DiskExt, Disks};
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
@@ -82,7 +82,7 @@ pub trait DiskExt: Debug {
     /// Returns the total disk size, in bytes.
     ///
     /// ```no_run
-    /// use sysinfo::{DiskExt, Disks, DisksExt};
+    /// use sysinfo::{DiskExt, Disks};
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
@@ -95,7 +95,7 @@ pub trait DiskExt: Debug {
     /// Returns the available disk size, in bytes.
     ///
     /// ```no_run
-    /// use sysinfo::{DiskExt, Disks, DisksExt};
+    /// use sysinfo::{DiskExt, Disks};
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
@@ -108,7 +108,7 @@ pub trait DiskExt: Debug {
     /// Returns `true` if the disk is removable.
     ///
     /// ```no_run
-    /// use sysinfo::{DiskExt, Disks, DisksExt};
+    /// use sysinfo::{DiskExt, Disks};
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
@@ -121,7 +121,7 @@ pub trait DiskExt: Debug {
     /// Updates the disk' information.
     ///
     /// ```no_run
-    /// use sysinfo::{DiskExt, Disks, DisksExt};
+    /// use sysinfo::{DiskExt, Disks};
     ///
     /// let mut disks = Disks::new();
     /// disks.refresh_list();
@@ -1480,128 +1480,6 @@ pub trait NetworksExt: Debug {
     fn refresh(&mut self);
 }
 
-/// Interacting with disks.
-///
-/// ```no_run
-/// use sysinfo::{Disks, DisksExt};
-///
-/// let mut disks = Disks::new();
-/// disks.refresh_list();
-/// for disk in disks.disks() {
-///     eprintln!("{disk:?}");
-/// }
-/// ```
-pub trait DisksExt: Debug {
-    /// Creates a new [`Disks`][crate::Disks] type.
-    ///
-    /// ```no_run
-    /// use sysinfo::{Disks, DisksExt};
-    ///
-    /// let mut disks = Disks::new();
-    /// disks.refresh_list();
-    /// for disk in disks.disks() {
-    ///     eprintln!("{disk:?}");
-    /// }
-    /// ```
-    fn new() -> Self;
-
-    /// Returns the disks list.
-    ///
-    /// ```no_run
-    /// use sysinfo::{Disks, DisksExt};
-    ///
-    /// let mut disks = Disks::new();
-    /// disks.refresh_list();
-    /// for disk in disks.disks() {
-    ///     eprintln!("{disk:?}");
-    /// }
-    /// ```
-    fn disks(&self) -> &[Disk];
-
-    /// Returns the disks list.
-    ///
-    /// ```no_run
-    /// use sysinfo::{DiskExt, Disks, DisksExt};
-    ///
-    /// let mut disks = Disks::new();
-    /// disks.refresh_list();
-    /// for disk in disks.disks_mut() {
-    ///     disk.refresh();
-    ///     eprintln!("{disk:?}");
-    /// }
-    /// ```
-    fn disks_mut(&mut self) -> &mut [Disk];
-
-    /// Sort the disk 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::{DiskExt, DisksExt, Disks};
-    ///
-    /// let mut disks = Disks::new();
-    /// disks.refresh_list();
-    /// disks.sort_by(|disk1, disk2| {
-    ///     disk1.name().partial_cmp(disk2.name()).unwrap()
-    /// });
-    /// ```
-    ///
-    /// ⚠️ If you use [`DisksExt::refresh_list`], you will need to call this method to sort the
-    /// disks again.
-    fn sort_by<F>(&mut self, compare: F)
-    where
-        F: FnMut(&Disk, &Disk) -> std::cmp::Ordering,
-    {
-        self.disks_mut().sort_unstable_by(compare);
-    }
-
-    /// Refreshes the listed disks' information.
-    ///
-    /// ⚠️ If a disk is added or removed, this method won't take it into account. Use
-    /// [`DisksExt::refresh_list`] instead.
-    ///
-    /// ⚠️ If you didn't call [`DisksExt::refresh_list`] beforehand, this method will do nothing as
-    /// the disk list will be empty.
-    ///
-    /// ```no_run
-    /// use sysinfo::{Disks, DisksExt};
-    ///
-    /// let mut disks = Disks::new();
-    /// // We get the disk list.
-    /// disks.refresh_list();
-    /// // We wait some time...?
-    /// disks.refresh();
-    /// ```
-    fn refresh(&mut self) {
-        for disk in self.disks_mut() {
-            disk.refresh();
-        }
-    }
-
-    /// The disk list will be emptied then completely recomputed.
-    ///
-    /// ## Linux
-    ///
-    /// ⚠️ On Linux, the [NFS](https://en.wikipedia.org/wiki/Network_File_System) file
-    /// systems are ignored and the information of a mounted NFS **cannot** be obtained
-    /// via [`DisksExt::refresh_list`]. This is due to the fact that I/O function
-    /// `statvfs` used by [`DisksExt::refresh_list`] is blocking and
-    /// [may hang](https://github.com/GuillaumeGomez/sysinfo/pull/876) in some cases,
-    /// requiring to call `systemctl stop` to terminate the NFS service from the remote
-    /// server in some cases.
-    ///
-    /// ```no_run
-    /// use sysinfo::{Disks, DisksExt};
-    ///
-    /// let mut disks = Disks::new();
-    /// disks.refresh_list();
-    /// ```
-    fn refresh_list(&mut self);
-}
-
 /// Getting a component temperature information.
 ///
 /// ```no_run
diff --git a/src/unix/apple/disk.rs b/src/unix/apple/disk.rs
index 8b7391e..9ebc9c4 100644
--- a/src/unix/apple/disk.rs
+++ b/src/unix/apple/disk.rs
@@ -4,7 +4,7 @@ use crate::sys::{
     ffi,
     utils::{self, CFReleaser},
 };
-use crate::{DiskExt, DiskKind, Disks, DisksExt};
+use crate::{DiskExt, DiskKind};
 
 use core_foundation_sys::array::CFArrayCreate;
 use core_foundation_sys::base::kCFAllocatorDefault;
@@ -81,24 +81,24 @@ impl DiskExt for Disk {
     }
 }
 
-impl DisksExt for Disks {
-    fn new() -> Self {
+impl crate::DisksInner {
+    pub(crate) fn new() -> Self {
         Self {
             disks: Vec::with_capacity(2),
         }
     }
 
-    fn refresh_list(&mut self) {
+    pub(crate) fn refresh_list(&mut self) {
         unsafe {
             get_disks(&mut self.disks);
         }
     }
 
-    fn disks(&self) -> &[Disk] {
+    pub(crate) fn disks(&self) -> &[Disk] {
         &self.disks
     }
 
-    fn disks_mut(&mut self) -> &mut [Disk] {
+    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
         &mut self.disks
     }
 }
diff --git a/src/unix/apple/mod.rs b/src/unix/apple/mod.rs
index ca7f299..6c825b5 100644
--- a/src/unix/apple/mod.rs
+++ b/src/unix/apple/mod.rs
@@ -32,3 +32,4 @@ pub use self::process::Process;
 pub use self::system::System;
 pub(crate) use crate::unix::users::get_users;
 pub use crate::unix::users::User;
+pub(crate) use crate::unix::DisksInner;
diff --git a/src/unix/freebsd/disk.rs b/src/unix/freebsd/disk.rs
index 7c40a1e..8db6f8d 100644
--- a/src/unix/freebsd/disk.rs
+++ b/src/unix/freebsd/disk.rs
@@ -1,6 +1,6 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-use crate::{DiskExt, DiskKind, Disks, DisksExt};
+use crate::{DiskExt, DiskKind};
 
 use std::ffi::{OsStr, OsString};
 use std::path::{Path, PathBuf};
@@ -55,22 +55,22 @@ impl DiskExt for Disk {
     }
 }
 
-impl DisksExt for Disks {
-    fn new() -> Self {
+impl crate::DisksInner {
+    pub(crate) fn new() -> Self {
         Self {
             disks: Vec::with_capacity(2),
         }
     }
 
-    fn refresh_list(&mut self) {
+    pub(crate) fn refresh_list(&mut self) {
         unsafe { get_all_disks(&mut self.disks) }
     }
 
-    fn disks(&self) -> &[Disk] {
+    pub(crate) fn disks(&self) -> &[Disk] {
         &self.disks
     }
 
-    fn disks_mut(&mut self) -> &mut [Disk] {
+    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
         &mut self.disks
     }
 }
diff --git a/src/unix/freebsd/mod.rs b/src/unix/freebsd/mod.rs
index 2575a81..d53ed39 100644
--- a/src/unix/freebsd/mod.rs
+++ b/src/unix/freebsd/mod.rs
@@ -16,3 +16,4 @@ pub use self::process::Process;
 pub use self::system::System;
 pub(crate) use crate::unix::users::get_users;
 pub use crate::unix::users::User;
+pub(crate) use crate::unix::DisksInner;
diff --git a/src/unix/linux/disk.rs b/src/unix/linux/disk.rs
index bd2aabf..03faf33 100644
--- a/src/unix/linux/disk.rs
+++ b/src/unix/linux/disk.rs
@@ -1,7 +1,7 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
 use crate::sys::utils::{get_all_data, to_cpath};
-use crate::{DiskExt, DiskKind, Disks, DisksExt};
+use crate::{DiskExt, DiskKind};
 
 use libc::statvfs;
 use std::ffi::{OsStr, OsString};
@@ -72,25 +72,25 @@ impl DiskExt for Disk {
     }
 }
 
-impl DisksExt for Disks {
-    fn new() -> Self {
+impl crate::DisksInner {
+    pub(crate) fn new() -> Self {
         Self {
             disks: Vec::with_capacity(2),
         }
     }
 
-    fn refresh_list(&mut self) {
+    pub(crate) fn refresh_list(&mut self) {
         get_all_disks(
             &mut self.disks,
             &get_all_data("/proc/mounts", 16_385).unwrap_or_default(),
         )
     }
 
-    fn disks(&self) -> &[Disk] {
+    pub(crate) fn disks(&self) -> &[Disk] {
         &self.disks
     }
 
-    fn disks_mut(&mut self) -> &mut [Disk] {
+    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
         &mut self.disks
     }
 }
diff --git a/src/unix/linux/mod.rs b/src/unix/linux/mod.rs
index 6006d61..9d0cf45 100644
--- a/src/unix/linux/mod.rs
+++ b/src/unix/linux/mod.rs
@@ -16,3 +16,4 @@ pub use self::process::Process;
 pub use self::system::System;
 pub(crate) use crate::unix::users::get_users;
 pub use crate::unix::users::User;
+pub(crate) use crate::unix::DisksInner;
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 8c745d6..3596c21 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -27,3 +27,7 @@ cfg_if::cfg_if! {
 pub(crate) mod network_helper;
 pub(crate) mod users;
 pub(crate) mod utils;
+
+pub(crate) struct DisksInner {
+    pub(crate) disks: Vec<crate::Disk>,
+}
diff --git a/src/unknown/disk.rs b/src/unknown/disk.rs
index e38e38d..ef854c4 100644
--- a/src/unknown/disk.rs
+++ b/src/unknown/disk.rs
@@ -1,6 +1,6 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-use crate::{DiskExt, DiskKind, Disks, DisksExt};
+use crate::{DiskExt, DiskKind};
 
 use std::{ffi::OsStr, path::Path};
 
@@ -41,20 +41,22 @@ impl DiskExt for Disk {
     }
 }
 
-impl DisksExt for Disks {
-    fn new() -> Self {
-        Self { disks: Vec::new() }
+pub(crate) struct DisksInner;
+
+impl DisksInner {
+    pub(crate) fn new() -> Self {
+        Self
     }
 
-    fn refresh_list(&mut self) {
+    pub(crate) fn refresh_list(&mut self) {
         // Does nothing.
     }
 
-    fn disks(&self) -> &[Disk] {
-        &self.disks
+    pub(crate) fn disks(&self) -> &[Disk] {
+        &[]
     }
 
-    fn disks_mut(&mut self) -> &mut [Disk] {
-        &mut self.disks
+    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
+        &mut []
     }
 }
diff --git a/src/unknown/mod.rs b/src/unknown/mod.rs
index d7c9c97..f6a442d 100644
--- a/src/unknown/mod.rs
+++ b/src/unknown/mod.rs
@@ -11,6 +11,7 @@ pub mod users;
 pub use self::component::{Component, Components};
 pub use self::cpu::Cpu;
 pub use self::disk::Disk;
+pub(crate) use self::disk::DisksInner;
 pub use self::network::NetworkData;
 pub use self::process::Process;
 pub use self::system::System;
diff --git a/src/windows/disk.rs b/src/windows/disk.rs
index 2213d09..45cb965 100644
--- a/src/windows/disk.rs
+++ b/src/windows/disk.rs
@@ -1,6 +1,6 @@
 // Take a look at the license at the top of the repository in the LICENSE file.
 
-use crate::{DiskExt, DiskKind, Disks, DisksExt};
+use crate::{DiskExt, DiskKind};
 
 use std::ffi::{c_void, OsStr, OsString};
 use std::mem::size_of;
@@ -75,24 +75,28 @@ impl DiskExt for Disk {
     }
 }
 
-impl DisksExt for Disks {
-    fn new() -> Self {
+pub(crate) struct DisksInner {
+    pub(crate) disks: Vec<Disk>,
+}
+
+impl DisksInner {
+    pub(crate) fn new() -> Self {
         Self {
             disks: Vec::with_capacity(2),
         }
     }
 
-    fn refresh_list(&mut self) {
+    pub(crate) fn refresh_list(&mut self) {
         unsafe {
             self.disks = get_disks();
         }
     }
 
-    fn disks(&self) -> &[Disk] {
+    pub(crate) fn disks(&self) -> &[Disk] {
         &self.disks
     }
 
-    fn disks_mut(&mut self) -> &mut [Disk] {
+    pub(crate) fn disks_mut(&mut self) -> &mut [Disk] {
         &mut self.disks
     }
 }
diff --git a/src/windows/mod.rs b/src/windows/mod.rs
index 4c91846..c9da726 100644
--- a/src/windows/mod.rs
+++ b/src/windows/mod.rs
@@ -15,6 +15,7 @@ mod utils;
 pub use self::component::{Component, Components};
 pub use self::cpu::Cpu;
 pub use self::disk::Disk;
+pub(crate) use self::disk::DisksInner;
 pub use self::network::NetworkData;
 pub use self::process::Process;
 pub use self::sid::Sid;


Test patch:
diff --git a/tests/disk_list.rs b/tests/disk_list.rs
index 2d3ab1e..0e857ac 100644
--- a/tests/disk_list.rs
+++ b/tests/disk_list.rs
@@ -2,7 +2,7 @@
 
 #[test]
 fn test_disks() {
-    use sysinfo::{DisksExt, SystemExt};
+    use sysinfo::SystemExt;
 
     if sysinfo::System::IS_SUPPORTED {
         let s = sysinfo::System::new_all();