pub struct FileExplorerNode {
pub entry: FileEntry,
pub children: Vec<FileExplorerNode>,
pub disabled: bool,
}Expand description
Caller-owned recursive file-explorer node.
A directory-like entry is a branch even with no loaded children. Conversely, any entry with children is treated as a branch so callers can use synthetic grouping rows. The model performs no URI uniqueness validation.
§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorerNode;
let node = FileExplorerNode::directory(FileUri::parse("file:///repo")?, "repo")
.child(FileExplorerNode::file(FileUri::parse("file:///repo/main.rs")?, "main.rs"));
assert!(node.is_branch());Fields§
§entry: FileEntryURI, display name, and filesystem metadata snapshot.
children: Vec<FileExplorerNode>Children in caller or sorted presentation order.
disabled: boolWhether interaction with this row is suppressed.
Implementations§
Source§impl FileExplorerNode
impl FileExplorerNode
Sourcepub fn new(entry: FileEntry) -> Self
pub fn new(entry: FileEntry) -> Self
Creates an enabled leaf candidate with no children.
Branch status still follows entry.metadata.is_directory_like().
§Examples
use ailloli_ui_fs::{FileEntry, FileKind, FileMetadata, FileUri};
use ailloli_ui_widgets::files::FileExplorerNode;
let entry = FileEntry::new(FileUri::parse("file:///a.txt")?, FileMetadata::new(FileKind::File));
let node = FileExplorerNode::new(entry);
assert!(node.children.is_empty() && !node.disabled);Sourcepub fn named(uri: FileUri, name: impl Into<String>, kind: FileKind) -> Self
pub fn named(uri: FileUri, name: impl Into<String>, kind: FileKind) -> Self
Creates an enabled node with an explicit display name and basic metadata.
The name is stored verbatim and need not match the URI filename.
§Examples
use ailloli_ui_fs::{FileKind, FileUri};
use ailloli_ui_widgets::files::FileExplorerNode;
let node = FileExplorerNode::named(FileUri::parse("file:///raw")?, "Alias", FileKind::Other);
assert_eq!(node.name(), "Alias");Sourcepub fn file(uri: FileUri, name: impl Into<String>) -> Self
pub fn file(uri: FileUri, name: impl Into<String>) -> Self
Creates an enabled [FileKind::File] node.
§Examples
use ailloli_ui_fs::{FileKind, FileUri};
use ailloli_ui_widgets::files::FileExplorerNode;
let node = FileExplorerNode::file(FileUri::parse("file:///main.rs")?, "main.rs");
assert_eq!(node.entry.metadata.kind, FileKind::File);Sourcepub fn directory(uri: FileUri, name: impl Into<String>) -> Self
pub fn directory(uri: FileUri, name: impl Into<String>) -> Self
Creates an enabled [FileKind::Directory] node.
§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorerNode;
let node = FileExplorerNode::directory(FileUri::parse("file:///src")?, "src");
assert!(node.is_branch());Sourcepub fn child(self, child: FileExplorerNode) -> Self
pub fn child(self, child: FileExplorerNode) -> Self
Appends one child after existing children.
§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorerNode;
let root = FileExplorerNode::directory(FileUri::parse("file:///")?, "/")
.child(FileExplorerNode::file(FileUri::parse("file:///a")?, "a"));
assert_eq!(root.children.len(), 1);Sourcepub fn children(
self,
children: impl IntoIterator<Item = FileExplorerNode>,
) -> Self
pub fn children( self, children: impl IntoIterator<Item = FileExplorerNode>, ) -> Self
Extends children in iterator order without replacing existing entries.
§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorerNode;
let node = FileExplorerNode::directory(FileUri::parse("file:///src")?, "src").children([
FileExplorerNode::file(FileUri::parse("file:///src/a.rs")?, "a.rs"),
FileExplorerNode::file(FileUri::parse("file:///src/b.rs")?, "b.rs"),
]);
assert_eq!(node.children.len(), 2);Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Sets whether pointer/keyboard actions are suppressed for this row.
§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorerNode;
let node = FileExplorerNode::file(FileUri::parse("file:///locked")?, "locked").disabled(true);
assert!(node.disabled);Sourcepub fn uri(&self) -> &FileUri
pub fn uri(&self) -> &FileUri
Borrows the entry’s canonical interaction key.
§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorerNode;
let uri = FileUri::parse("file:///a")?;
assert_eq!(FileExplorerNode::file(uri.clone(), "a").uri(), &uri);Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Borrows the caller-provided display name.
§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorerNode;
let node = FileExplorerNode::file(FileUri::parse("file:///a")?, "Alias");
assert_eq!(node.name(), "Alias");Sourcepub fn is_branch(&self) -> bool
pub fn is_branch(&self) -> bool
Reports whether the row can represent expandable children.
Directory-like metadata or any non-empty child list makes a branch; broken/file symlinks with no children remain leaves.
§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorerNode;
assert!(!FileExplorerNode::file(FileUri::parse("file:///a")?, "a").is_branch());
assert!(FileExplorerNode::directory(FileUri::parse("file:///d")?, "d").is_branch());Trait Implementations§
Source§impl Clone for FileExplorerNode
impl Clone for FileExplorerNode
Source§fn clone(&self) -> FileExplorerNode
fn clone(&self) -> FileExplorerNode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileExplorerNode
impl Debug for FileExplorerNode
Source§impl PartialEq for FileExplorerNode
impl PartialEq for FileExplorerNode
impl Eq for FileExplorerNode
impl StructuralPartialEq for FileExplorerNode
Auto Trait Implementations§
impl Freeze for FileExplorerNode
impl RefUnwindSafe for FileExplorerNode
impl Send for FileExplorerNode
impl Sync for FileExplorerNode
impl Unpin for FileExplorerNode
impl UnwindSafe for FileExplorerNode
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.