pub struct FileCollection { /* private fields */ }Expand description
A name-sorted list of SearchRec items.
The only real behaviour it carries is the sorted insert and its comparator
(search_rec_compare). The sort order is: plain files alphabetically
(case-sensitive), then directories alphabetically, then ".." last.
§Turbo Vision heritage
Ports TFileCollection (filedial.cpp), a sorted heap collection; here only
the sorted insert survives, over a plain Vec.
Implementations§
Source§impl FileCollection
impl FileCollection
Sourcepub fn insert(&mut self, rec: SearchRec)
pub fn insert(&mut self, rec: SearchRec)
Insert rec while keeping the list sorted by search_rec_compare.
Duplicate names do not occur in a real directory listing.
Sourcepub fn at(&self, index: usize) -> Option<&SearchRec>
pub fn at(&self, index: usize) -> Option<&SearchRec>
Borrow the record at index, or None when out of bounds (never panics).
Used by FileList to fetch the entry at a given list position. Prefer
items and standard slice indexing when you need
to iterate; use at when you already have a positional index from the
list-viewer (e.g. the focused item).
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of records currently in the sorted listing.
Mirrors the list-viewer’s range after a FileList::read_directory
call. Use is_empty to gate iteration.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true when the collection holds no records.
Returned true before the first insert and
after a directory with no matching files is read.
Sourcepub fn items(&self) -> &[SearchRec]
pub fn items(&self) -> &[SearchRec]
Borrow the sorted records as a slice, in search_rec_compare order.
Use this to iterate all entries or binary-search without consuming the
collection. FileList::build_listing calls this to hand the sorted slice
off to the list-viewer state.
Sourcepub fn into_items(self) -> Vec<SearchRec>
pub fn into_items(self) -> Vec<SearchRec>
Consume the collection and return its sorted records by value.
Avoids a clone when the FileCollection is a short-lived temporary.
FileList::build_listing uses this to transfer the sorted Vec directly
into self.items without an extra allocation.
Trait Implementations§
Source§impl Clone for FileCollection
impl Clone for FileCollection
Source§fn clone(&self) -> FileCollection
fn clone(&self) -> FileCollection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileCollection
impl Debug for FileCollection
Source§impl Default for FileCollection
impl Default for FileCollection
Source§fn default() -> FileCollection
fn default() -> FileCollection
impl Eq for FileCollection
Source§impl PartialEq for FileCollection
impl PartialEq for FileCollection
impl StructuralPartialEq for FileCollection
Auto Trait Implementations§
impl Freeze for FileCollection
impl RefUnwindSafe for FileCollection
impl Send for FileCollection
impl Sync for FileCollection
impl Unpin for FileCollection
impl UnsafeUnpin for FileCollection
impl UnwindSafe for FileCollection
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.