1#![doc = include_str!("../README.md")]
2
3use std::{error::Error, path::PathBuf};
4
5use disk::{get_disk_paths, Disk};
6
7pub mod ata;
8pub mod attribute;
9pub mod benchmark;
10pub mod disk;
11pub mod kind;
12pub mod sysfs;
13
14pub use libatasmart;
16pub use libatasmart_sys;
17
18#[cfg(target_os = "linux")]
19static DEV_PATH: &str = "/dev";
20
21pub fn list_disks() -> Result<Vec<Disk>, Box<dyn Error>> {
23 let mut list = vec![];
24 let disks = get_disk_paths()?;
25
26 for disk in disks {
27 let d = Disk::new(PathBuf::from(format!("{}/{}", DEV_PATH, disk)));
28
29 if let Ok(d) = d {
30 list.push(d);
31 }
32 }
33
34 Ok(list)
35}