Struct FileTreeNode

Source
pub struct FileTreeNode { /* private fields */ }
Expand description

Retained node in a FileTreeStore.

Nodes expose immutable snapshots; all mutation goes through the store so its URI/identity indexes and deltas remain coherent.

§Examples

use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert_eq!(store.node(store.root()).unwrap().id(), store.root());

Implementations§

Source§

impl FileTreeNode

Source

pub const fn id(&self) -> FileTreeNodeId

Returns the opaque store-local node ID.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert_eq!(store.node(store.root()).unwrap().id().get(), 1);
Source

pub const fn parent(&self) -> Option<FileTreeNodeId>

Returns the parent ID, or None for the root.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert_eq!(store.node(store.root()).unwrap().parent(), None);
Source

pub fn uri(&self) -> &FileUri

Borrows the node’s current URI.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert_eq!(store.node(store.root()).unwrap().uri().path(), "/");
Source

pub fn identity(&self) -> Option<&FileIdentity>

Borrows the provider identity, or None when unavailable.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert!(store.node(store.root()).unwrap().identity().is_none());
Source

pub const fn metadata(&self) -> &FileMetadata

Borrows the latest metadata snapshot.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert_eq!(store.node(store.root()).unwrap().metadata().kind, FileKind::Directory);
Source

pub fn children(&self) -> &[FileTreeNodeId]

Borrows child IDs in provider/reconciliation order.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert!(store.node(store.root()).unwrap().children().is_empty());
Source

pub const fn directory_state(&self) -> &DirectoryLoadState

Borrows the retained directory-load state.

Non-directory nodes also begin as DirectoryLoadState::Unloaded; a load request still rejects them.

§Examples
use ailloli_ui_fs::{DirectoryLoadState, FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert!(matches!(store.node(store.root()).unwrap().directory_state(), DirectoryLoadState::Unloaded));
Source

pub const fn is_expanded(&self) -> bool

Returns whether UI expansion currently pins and displays the node.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert!(!store.node(store.root()).unwrap().is_expanded());
Source

pub const fn is_selected(&self) -> bool

Returns whether the node participates in the current selection.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert!(!store.node(store.root()).unwrap().is_selected());
Source

pub const fn is_focused(&self) -> bool

Returns whether the node owns keyboard/navigation focus.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert!(!store.node(store.root()).unwrap().is_focused());
Source

pub const fn has_pending_operation(&self) -> bool

Returns whether provider mutation is pending for this node.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
assert!(!store.node(store.root()).unwrap().has_pending_operation());
Source

pub const fn is_pinned(&self) -> bool

Returns whether any expansion, selection, focus, or pending-operation flag is set.

Pinned nodes prevent eviction of their containing candidate subtree.

§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
let mut store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
store.set_selected(store.root(), true)?;
assert!(store.node(store.root()).unwrap().is_pinned());

Trait Implementations§

Source§

impl Clone for FileTreeNode

Source§

fn clone(&self) -> FileTreeNode

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 FileTreeNode

Source§

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

Formats the value using the given formatter. Read more

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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.