Struct fsort::file_collection::StaticCollection
[−]
[src]
pub struct StaticCollection<C: Criterion> { /* fields omitted */ }
A sorted collection of files with fixed criterion.
Methods
impl<C: Criterion> StaticCollection<C>
[src]
fn new() -> StaticCollection<C>
Creates a new sorted collection with a specific criterion.
Examples
use fsort::criterion::FileName; use fsort::file_collection::StaticCollection; let collection = StaticCollection::<FileName>::new();
fn iter(&self) -> FileIter<C>
Returns an iterator over the sorted files in the collection according to the criterion.
Examples
use std::fs::File; use std::path::PathBuf; use fsort::criterion::FileName; use fsort::file_collection::StaticCollection; use fsort::file_collection::FileCollection; let mut i1 = std::env::temp_dir(); let mut i2 = std::env::temp_dir(); i1.push("I1.tmp"); i2.push("I2.tmp"); File::create(&i1).unwrap(); File::create(&i2).unwrap(); // Inserts files into collection let mut collection = StaticCollection::<FileName>::new(); collection.add_file(&i2); collection.add_file(&i1); let mut iter = collection.iter(); assert_eq!(i1, iter.next().unwrap().path); assert_eq!(i2, iter.next().unwrap().path); assert_eq!(None, iter.next());
Trait Implementations
impl<C: Criterion> FileCollection for StaticCollection<C>
[src]
fn add_file(&mut self, path: &Path) -> Result
Adds a file to the collection. # Examples See DynamicCollection::set_criterion
Read more
fn add_directory(
&mut self,
path: &Path,
recursive: bool,
error_behavior: ErrorBehavior
) -> Result
&mut self,
path: &Path,
recursive: bool,
error_behavior: ErrorBehavior
) -> Result
Adds all files of a directory to the collection.
fn set_order(&mut self, order: Order)
Sets the current order of the collection.
fn get_order(&self) -> Order
Returns the current order of the collection.
fn path_iter(&self) -> PathIter
Returns an iterator about all the (sorted) paths in the collection according to the order. # Examples See DynamicCollection::set_criterion
Read more
impl<C: Criterion> IntoIterator for StaticCollection<C>
[src]
type Item = PathBuf
The type of the elements being iterated over.
type IntoIter = PathIter
Which kind of iterator are we turning this into?
fn into_iter(self) -> PathIter
Creates an iterator from a value. Read more
impl<C: Criterion> Default for StaticCollection<C>
[src]
fn default() -> StaticCollection<C>
Returns the "default value" for a type. Read more