Struct FileTreeReconcileScheduler

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

Source

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

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

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

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

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

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

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

pub fn len(&self) -> usize

Returns the number of expanded nodes scheduled for polling.

§Examples
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
assert_eq!(FileTreeReconcileScheduler::new(false).len(), 0);
Source

pub fn is_empty(&self) -> bool

Reports whether no directory is scheduled for polling.

§Examples
use ailloli_ui_fs_runtime::FileTreeReconcileScheduler;
assert!(FileTreeReconcileScheduler::new(true).is_empty());

Trait Implementations§

Source§

impl Debug for FileTreeReconcileScheduler

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> 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> Same for T

Source§

type Output = T

Should always be Self
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> ErasedDestructor for T
where T: 'static,