pub struct FileTreeModelBridge { /* private fields */ }Expand description
Applies precise filesystem deltas to a retained UI model without exporting or cloning a recursive tree snapshot.
Node identifiers are preserved exactly. Construction performs an iterative
depth-first projection of the complete retained store; later updates mutate
one shared TreeModelHandle in place.
§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
use ailloli_ui_widgets::files::FileTreeModelBridge;
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
let bridge = FileTreeModelBridge::from_store(&store)?;
assert!(bridge.model().read(|model| model.item(&store.root()).is_some()));Implementations§
Source§impl FileTreeModelBridge
impl FileTreeModelBridge
Sourcepub fn from_store(
store: &FileTreeStore,
) -> Result<Self, FileTreeModelBridgeError>
pub fn from_store( store: &FileTreeStore, ) -> Result<Self, FileTreeModelBridgeError>
Projects every current store node into a new retained model.
Store child order becomes model child order, and expanded directory-like nodes remain expanded.
§Errors
Returns FileTreeModelBridgeError::MissingNode for an inconsistent
child index, or FileTreeModelBridgeError::Model when the resulting
mutation batch violates retained-tree invariants.
§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
use ailloli_ui_widgets::files::FileTreeModelBridge;
let store = FileTreeStore::new(FileUri::parse("file:///workspace")?, FileMetadata::new(FileKind::Directory))?;
let bridge = FileTreeModelBridge::from_store(&store)?;
assert!(bridge.model().read(|model| model.item(&store.root()).is_some()));Sourcepub fn model(&self) -> TreeModelHandle<FileTreeNodeId>
pub fn model(&self) -> TreeModelHandle<FileTreeNodeId>
Clones the handle to the bridge’s shared retained tree model.
Cloning the handle does not clone the tree: updates applied through this bridge are immediately visible through every returned handle.
§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
use ailloli_ui_widgets::files::FileTreeModelBridge;
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
let bridge = FileTreeModelBridge::from_store(&store)?;
let model = bridge.model();
assert!(model.read(|tree| tree.item(&store.root()).is_some()));Sourcepub fn apply_delta(
&self,
store: &FileTreeStore,
delta: &FileTreeStoreDelta,
) -> Result<(), FileTreeModelBridgeError>
pub fn apply_delta( &self, store: &FileTreeStore, delta: &FileTreeStoreDelta, ) -> Result<(), FileTreeModelBridgeError>
Applies an ordered filesystem-store delta to the shared UI model.
Inserts, removals, moves, metadata updates, and directory-state updates are batched atomically. Updates for a node already absent from the final store remove any stale model row; unsupported delta variants are ignored.
§Errors
Returns FileTreeModelBridgeError::Model if the translated batch would
violate retained-tree identity, parent, or ordering invariants.
§Examples
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
use ailloli_ui_widgets::files::FileTreeModelBridge;
let mut store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
let bridge = FileTreeModelBridge::from_store(&store)?;
let delta = store.set_expanded(store.root(), true)?;
bridge.apply_delta(&store, &delta)?;
assert!(bridge.model().read(|model| model.is_expanded(&store.root())));Trait Implementations§
Source§impl Clone for FileTreeModelBridge
impl Clone for FileTreeModelBridge
Source§fn clone(&self) -> FileTreeModelBridge
fn clone(&self) -> FileTreeModelBridge
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FileTreeModelBridge
impl !RefUnwindSafe for FileTreeModelBridge
impl !Send for FileTreeModelBridge
impl !Sync for FileTreeModelBridge
impl Unpin for FileTreeModelBridge
impl !UnwindSafe for FileTreeModelBridge
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<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.