Struct broot::filesystems::MountList
source · pub struct MountList { /* private fields */ }
Implementations§
source§impl MountList
impl MountList
sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
sourcepub fn load(&mut self) -> Result<&Vec<Mount>, ProgramError>
pub fn load(&mut self) -> Result<&Vec<Mount>, ProgramError>
try to load the mounts if they aren’t loaded.
Examples found in repository?
More examples
src/filesystems/filesystems_state.rs (line 63)
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
pub fn new(
path: Option<&Path>,
tree_options: TreeOptions,
con: &AppContext,
) -> Result<FilesystemState, ProgramError> {
let mut mount_list = MOUNTS.lock().unwrap();
let show_only_disks = false;
let mounts = mount_list
.load()?
.iter()
.filter(|mount| {
if show_only_disks {
mount.disk.is_some()
} else {
mount.stats().is_some()
}
})
.cloned()
.collect::<Vec<Mount>>();
let mounts: NonEmptyVec<Mount> = match mounts.try_into() {
Ok(nev) => nev,
_ => {
return Err(ProgramError::Lfs {
details: "no disk in lfs-core list".to_string(),
});
}
};
let selection_idx = path
.and_then(|path| fs::metadata(path).ok())
.and_then(|md| {
let device_id = md.dev().into();
mounts.iter().position(|m| m.info.dev == device_id)
})
.unwrap_or(0);
Ok(FilesystemState {
mounts,
selection_idx,
scroll: 0,
page_height: 0,
tree_options,
filtered: None,
mode: initial_mode(con),
})
}