pub enum PathSource {
Local,
LocalDesktop,
LocalFlatpak,
LocalNix,
Nix,
System,
SystemLocal,
SystemFlatpak,
SystemSnap,
Other(String),
}Variants§
Local
LocalDesktop
LocalFlatpak
LocalNix
Nix
System
SystemLocal
SystemFlatpak
SystemSnap
Other(String)
Implementations§
source§impl PathSource
impl PathSource
sourcepub fn guess_from(path: &Path) -> PathSource
pub fn guess_from(path: &Path) -> PathSource
Attempts to determine the PathSource for a given Path. Note that this is a best-effort guesting function, and its results should be treated as such (e.g.: non-canonical).
Examples found in repository?
examples/all_files.rs (line 14)
10 11 12 13 14 15 16 17 18 19 20 21
fn main() {
let locales = get_languages_from_env();
for path in Iter::new(default_paths()) {
let path_src = PathSource::guess_from(&path);
if let Ok(bytes) = fs::read_to_string(&path) {
if let Ok(entry) = DesktopEntry::from_str(&path, &bytes, &locales) {
println!("{:?}: {}\n---\n{}", path_src, path.display(), entry);
}
}
}
}Trait Implementations§
source§impl Clone for PathSource
impl Clone for PathSource
source§fn clone(&self) -> PathSource
fn clone(&self) -> PathSource
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for PathSource
impl Debug for PathSource
source§impl Hash for PathSource
impl Hash for PathSource
source§impl PartialEq for PathSource
impl PartialEq for PathSource
source§fn eq(&self, other: &PathSource) -> bool
fn eq(&self, other: &PathSource) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Eq for PathSource
impl StructuralPartialEq for PathSource
Auto Trait Implementations§
impl Freeze for PathSource
impl RefUnwindSafe for PathSource
impl Send for PathSource
impl Sync for PathSource
impl Unpin for PathSource
impl UnwindSafe for PathSource
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)