pub struct LsColors { /* private fields */ }
Expand description
Holds information about how different file system entries should be colorized / styled.
Implementations
sourceimpl LsColors
impl LsColors
sourcepub fn from_env() -> Option<Self>
pub fn from_env() -> Option<Self>
Creates a new LsColors
instance from the LS_COLORS
environment variable.
sourcepub fn from_string(input: &str) -> Self
pub fn from_string(input: &str) -> Self
Creates a new LsColors
instance from the given string.
sourcepub fn style_for_path<P: AsRef<Path>>(&self, path: P) -> Option<&Style>
pub fn style_for_path<P: AsRef<Path>>(&self, path: P) -> Option<&Style>
Get the ANSI style for a given path.
Note: this function calls Path::symlink_metadata
internally. If you already happen to
have the Metadata
available, use style_for_path_with_metadata
.
sourcepub fn style_for_path_with_metadata<P: AsRef<Path>>(
&self,
path: P,
metadata: Option<&Metadata>
) -> Option<&Style>
pub fn style_for_path_with_metadata<P: AsRef<Path>>(
&self,
path: P,
metadata: Option<&Metadata>
) -> Option<&Style>
Get the ANSI style for a path, given the corresponding Metadata
struct.
Note: The Metadata
struct must have been acquired via Path::symlink_metadata
in
order to colorize symbolic links correctly.
sourcepub fn style_for_path_components<P: AsRef<Path>>(
&self,
path: P
) -> Vec<(OsString, Option<&Style>)>
pub fn style_for_path_components<P: AsRef<Path>>(
&self,
path: P
) -> Vec<(OsString, Option<&Style>)>
Get ANSI styles for each component of a given path. Components already
include the patj separator symbol, if required. For a path like
foo/bar/test.md
, this would return three pairs for the components
foo/
, bar/
and test.md
together with their respective styles.