Struct FileExplorerNode

Source
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: FileEntry

URI, display name, and filesystem metadata snapshot.

§children: Vec<FileExplorerNode>

Children in caller or sorted presentation order.

§disabled: bool

Whether interaction with this row is suppressed.

Implementations§

Source§

impl FileExplorerNode

Source

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);
Source

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");
Source

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);
Source

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());
Source

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);
Source

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);
Source

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);
Source

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);
Source

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");
Source

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

Source§

fn clone(&self) -> FileExplorerNode

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileExplorerNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for FileExplorerNode

Source§

fn eq(&self, other: &FileExplorerNode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for FileExplorerNode

Source§

impl StructuralPartialEq for FileExplorerNode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<A> IntoClickAction<A> for A
where A: Clone + 'static,

§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Props for T
where T: Clone + 'static,