pub struct FileTreeReconcileScheduler { /* private fields */ }Expand description
UI-owned targeted polling policy for sources without native watch support. Only expanded directories are scheduled; rendering never calls it.
§Examples
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
assert!(FileTreeReconcileScheduler::new(false).is_empty());
assert!(FileTreeReconcileScheduler::new(true).uses_native_watch());Implementations§
Source§impl FileTreeReconcileScheduler
Targeted expansion-driven polling operations.
impl FileTreeReconcileScheduler
Targeted expansion-driven polling operations.
Sourcepub fn new(native_watch: bool) -> Self
pub fn new(native_watch: bool) -> Self
Creates an empty scheduler for the provider’s watch capability.
A true value permanently disables schedule creation.
§Examples
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
let scheduler = FileTreeReconcileScheduler::new(true);
assert!(scheduler.uses_native_watch());
assert_eq!(scheduler.len(), 0);Sourcepub const fn uses_native_watch(&self) -> bool
pub const fn uses_native_watch(&self) -> bool
Reports the immutable provider watch mode selected at construction.
§Examples
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
assert!(!FileTreeReconcileScheduler::new(false).uses_native_watch());Sourcepub fn set_expanded(
&mut self,
node_id: FileTreeNodeId,
expanded: bool,
now: Instant,
)
pub fn set_expanded( &mut self, node_id: FileTreeNodeId, expanded: bool, now: Instant, )
Adds or removes polling for a directory’s expansion state.
Expanding an already scheduled node preserves its current deadline and
backoff. New non-native entries first become due two seconds after
now; collapsing removes them. Native-watch schedulers always stay empty.
§Examples
use std::time::Instant;
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
let mut scheduler = FileTreeReconcileScheduler::new(false);
scheduler.set_expanded(store.root(), true, Instant::now());
assert_eq!(scheduler.len(), 1);Sourcepub fn due(&self, now: Instant, limit: usize) -> Vec<FileTreeNodeId>
pub fn due(&self, now: Instant, limit: usize) -> Vec<FileTreeNodeId>
Returns at most limit due node IDs in ascending raw-ID order.
limit == 0 returns an empty vector without changing schedules.
§Examples
use std::time::Instant;
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
let scheduler = FileTreeReconcileScheduler::new(false);
assert!(scheduler.due(Instant::now(), 0).is_empty());Sourcepub fn next_due(&self) -> Option<Instant>
pub fn next_due(&self) -> Option<Instant>
Earliest instant at which a non-native expanded directory must be reconciled. Hosts use this to arm one targeted UI timer instead of polling from every frame.
Returns None when no directory is scheduled.
§Examples
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
assert_eq!(FileTreeReconcileScheduler::new(false).next_due(), None);Sourcepub fn note_success(&mut self, node_id: FileTreeNodeId, now: Instant)
pub fn note_success(&mut self, node_id: FileTreeNodeId, now: Instant)
Resets an existing node to the two-second base interval after success.
Unknown IDs are ignored.
§Examples
use std::time::Instant;
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
let mut scheduler = FileTreeReconcileScheduler::new(false);
scheduler.note_success(store.root(), Instant::now());
assert!(scheduler.is_empty());Sourcepub fn note_error(&mut self, node_id: FileTreeNodeId, now: Instant)
pub fn note_error(&mut self, node_id: FileTreeNodeId, now: Instant)
Doubles an existing node’s delay, saturating and clamping at 30 seconds.
Unknown IDs are ignored; overflow cannot exceed the public maximum.
§Examples
use std::time::Instant;
use ailloli_ui_fs::{FileKind, FileMetadata, FileTreeStore, FileUri};
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
let store = FileTreeStore::new(FileUri::parse("file:///")?, FileMetadata::new(FileKind::Directory))?;
let mut scheduler = FileTreeReconcileScheduler::new(false);
scheduler.note_error(store.root(), Instant::now());
assert_eq!(scheduler.len(), 0);