pub struct MountList { /* private fields */ }

Implementations§

Examples found in repository?
src/filesystems/mod.rs (line 19)
19
pub static MOUNTS: Lazy<Mutex<MountList>> = Lazy::new(|| Mutex::new(MountList::new()));
Examples found in repository?
src/filesystems/mod.rs (line 23)
21
22
23
24
pub fn clear_cache() {
    let mut mount_list = MOUNTS.lock().unwrap();
    mount_list.clear_cache();
}

try to load the mounts if they aren’t loaded.

Examples found in repository?
src/tree/tree_line.rs (line 114)
111
112
113
114
115
116
117
118
119
120
121
    pub fn mount(&self) -> Option<lfs_core::Mount> {
        use crate::filesystems::*;
        let mut mount_list = MOUNTS.lock().unwrap();
        if mount_list.load().is_ok() {
            mount_list
                .get_by_device_id(self.metadata.dev().into())
                .cloned()
        } else {
            None
        }
    }
More examples
Hide additional 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),
        })
    }
Examples found in repository?
src/tree/tree_line.rs (line 116)
111
112
113
114
115
116
117
118
119
120
121
    pub fn mount(&self) -> Option<lfs_core::Mount> {
        use crate::filesystems::*;
        let mut mount_list = MOUNTS.lock().unwrap();
        if mount_list.load().is_ok() {
            mount_list
                .get_by_device_id(self.metadata.dev().into())
                .cloned()
        } else {
            None
        }
    }

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.