Enum broot::tree::TreeLineType
source · pub enum TreeLineType {
File,
Dir,
BrokenSymLink(String),
SymLink {
direct_target: String,
final_is_dir: bool,
final_target: PathBuf,
},
Pruning,
}
Expand description
The type of a line which can be displayed as part of a tree
Variants§
Implementations§
source§impl TreeLineType
impl TreeLineType
sourcepub fn new(path: &Path, ft: &FileType) -> Self
pub fn new(path: &Path, ft: &FileType) -> Self
Examples found in repository?
src/tree_build/bline.rs (line 123)
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
pub fn to_tree_line(&self, bid: BId, con: &AppContext) -> std::io::Result<TreeLine> {
let has_error = self.has_error;
let line_type = TreeLineType::new(&self.path, &self.file_type);
let unlisted = if let Some(children) = &self.children {
// number of not listed children
children.len() - self.next_child_idx
} else {
0
};
let metadata = fs::symlink_metadata(&self.path)?;
let subpath = self.subpath.replace('\n', "");
let name = self.name.replace('\n', "");
let icon = con.icons.as_ref()
.map(|icon_plugin| {
let extension = TreeLine::extension_from_name(&name);
let double_extension = extension
.and_then(|_| TreeLine::double_extension_from_name(&name));
icon_plugin.get_icon(
&line_type,
&name,
double_extension,
extension,
)
});
Ok(TreeLine {
bid,
parent_bid: self.parent_id,
left_branchs: vec![false; self.depth as usize].into_boxed_slice(),
depth: self.depth,
icon,
name,
subpath,
path: self.path.clone(),
line_type,
has_error,
nb_kept_children: self.nb_kept_children as usize,
unlisted,
score: self.score,
direct_match: self.direct_match,
sum: None,
metadata,
git_status: None,
})
}
Trait Implementations§
source§impl Clone for TreeLineType
impl Clone for TreeLineType
source§fn clone(&self) -> TreeLineType
fn clone(&self) -> TreeLineType
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 TreeLineType
impl Debug for TreeLineType
source§impl PartialEq<TreeLineType> for TreeLineType
impl PartialEq<TreeLineType> for TreeLineType
source§fn eq(&self, other: &TreeLineType) -> bool
fn eq(&self, other: &TreeLineType) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.